1.0.12 • Published 5 months ago

nahtuh-client v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Nahtuh Client

Nahtuh client is a javascript library to use nahtuh API to develop real time collaboration application.

Contents

Getting Started

CDN

<!-- index.html -->
<script src="https://cdn.nahtuh.com/libraries/nahtuhclient.js"></script>
<script>
  const { nahtuhClient, identityManager } = window.NahtuhClient;
</script>

NPM

npm i nahtuh-client
import { nahtuhClient, identityManager } from 'nahtuh-client';

API Documentation

Connection API

Start Connection

Start websocket connection

// use this only when autoStart is set to false
let response = await nahtuhClient.start();

Stop Connection

Stop websocket connection

// use this only when autoStart is set to false
let response = await nahtuhClient.stop();

Event Management API

Create Event

let response = await nahtuhClient.createEvent(participantName, autoStart);
Parameters
NameNullableTypeDescription
participantNameNoStringnickname you want to use in the event
autoStartYesBooleanAuto Connect web socket when value is true
Response
NameTypeDescription
eventInfoEventInfo
participantParticipant
participantTokenParticipantToken

Join Event

let response = await nahtuhClient.join(eventId, participantName, autoStart);
Parameters
NameNullableTypeDescription
eventIdNoStringUnique Id of the event you want to join to
participantNameNoStringnickname you want to use in the event
autoStartYesBooleanAuto Connect web socket when value is true
Response
NameTypeDescription
eventInfoEventInfo
participantParticipant
participantTokenParticipantToken

Leave Event

let response = await nahtuhClient.leaveEvent(autoStop);
Parameters
NameNullableTypeDescription
autoStopYesBooleanAuto Disconnect web socket when value is true

Get Participant List

Get all participants in the current event

let response = await nahtuhClient.getParticipantList();
Response
NameTypeDescription
List

Get Current Participant

Get current participant info

let response = await nahtuhClient.getCurrentParticipant();
Response
NameTypeDescription
Participant

Group Management API

Join Group

Create or join existing group

let response = await nahtuhClient.joinGroup(participantId, groupName);
Parameters
NameNullableTypeDescription
participantIdNoString
groupNameNoString

Leave Group

let response = await nahtuhClient.leaveGroup(participantId, groupName);
Parameters
NameNullableTypeDescription
participantIdNoString
groupNameNoString

Get Group Member

Get all group members

let response = await nahtuhClient.getGroupMember(groupName);
Parameters
NameNullableTypeDescription
groupNameNoString
Response
NameTypeDescription
List

Host Configuration API

Host configuration is a configuration only the event's host can access. It can be useful to implement host rejoin functionality.

Set Host Configuration

await nahtuhClient.setHostConfiguration(config);
Parameters
NameNullableTypeDescription
configNoobjectany configuration you want to save

Get Host Configuration

var response = await nahtuhClient.getHostConfiguration();
Response
NameTypeDescription
objectconfiguration saved by the host

Messaging API

Broadcast

Send message to all event participants

let response = await nahtuhClient.broadcast(message);
Parameters
NameNullableTypeDescription
messageNoString

Send To User

Send message to a specific user

let response = await nahtuhClient.sendToUser(participantId, message);
Parameters
NameNullableTypeDescription
participantIdNoString
messageNoString

Send To Group

Send message to all participant in a specific group

let response = await nahtuhClient.sendToGroup(groupName, message);
Parameters
NameNullableTypeDescription
groupNameNoString
messageNoString

Event Handlers

On Participant Joined

Call back function when new participant join to an event

nahtuhClient.onParticipantJoined = (data) => {}
Data
NameTypeDescription
Participant

On Participant Leave

call back function when new participant leave an event

nahtuhClient.onParticipantLeave = (data) => {}
Data
NameTypeDescription
Participant

On Incoming Message

call back function when new message received

nahtuhClient.onIncomingMessage = (data) => {}
Data
NameTypeDescription
Message

On Group Member Joined

call back function when participant join to a group

nahtuhClient.onGroupMemberJoined = (data) => {}
Data
NameTypeDescription
groupNameString
participantIdString
participantNameString

On Group Member Left

call back function when participant left a group

nahtuhClient.onGroupMemberLeft = (data) => {}
Data
NameTypeDescription
groupNameString
participantIdString
participantNameString

Types

EventInfo

NameTypeDescription
activityIdStringUnique Id used by the activity created an activity is submitted to nahtuh
activitySetIdString
createdDateStringTimestamp of the event creation
eventIdStringUnique Id for the newly created event
invitationUrlString

Participant

NameTypeDescription
avatarUrlString
connectedBooleanconnection status of the websocket
isHostBoolean
participantIdString
participantNameString

ParticipantToken

NameTypeDescription
usernameString
accessTokenStringToken used to access nahtuh API
refreshTokenStringToken used to refresh accessToken

GroupMember

NameTypeDescription
participantIdString
participantNameString

Message

NameTypeDescription
methodStringBM = Broadcast Message, PM=Private Message, GM = Group Message
contentString
senderIdStringParticipantId of the sender
1.0.12

5 months ago

1.0.11

8 months ago

1.0.10

11 months ago

1.0.9

12 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1-14

2 years ago

1.0.1-13

2 years ago

1.0.1-11

2 years ago

1.0.1-10

3 years ago

1.0.1-4

3 years ago

1.0.1-3

3 years ago

1.0.1-6

3 years ago

1.0.1-5

3 years ago

1.0.1-8

3 years ago

1.0.1-7

3 years ago

1.0.1-9

3 years ago

1.0.1-2

3 years ago

1.0.1-1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago