Classes

Classes

Application
Conversation
ConversationsPage
EventsPage
ImageEvent
Media
Member
MembersPage
MessageEvent
NexmoApiError
NexmoClient
NexmoClientError
NXMCall
NXMEvent
TextEvent
UserSessionsPage

Events


call:status:changed

Application listening for nxmCall status changed events.

Properties:
Name Type Description
nxmCall NXMCall

the actual event

Source:
Example

listen for nxmCall status changed events on Application level

 application.on("call:status:changed",(nxmCall) => {
   console.log("call: " + nxmCall.status);
 });

NXM-errors

Application listening for client and expired-token errors events.

Properties:
Name Type Description
error NexmoClientError
Source:
Examples

listen for client error events on Application level

application.on('*', 'NXM-errors', (error) => {
   console.log('Error thrown with type ' + error.type);
 });

listen for expired-token error events and then update the token on Application level

application.on('system:error:expired-token', 'NXM-errors', (error) => {
	console.log('token expired');
	application.updateToken(token);
});

member:call

Application listening for member call events.

Properties:
Name Type Description
member Member

the member that initiated the nxmCall

nxmCall NXMCall

resolves the nxmCall object

Source:
Example

listen for member call events on Application level

 application.on("member:call", (member, nxmCall) => {
   console.log("NXMCall ", nxmCall);
 });

member:invited

Application listening for member invited events.

Properties:
Name Type Description
member Member

The invited member

event NXMEvent

The invitation event

Source:
Example

listen for member invited events on Application level

 application.on("member:invited",(member, event) => {
   console.log("Invited to the conversation: " + event.conversation.display_name || event.conversation.name);
   // identify the sender.
   console.log("Invited by: " + member.invited_by);
   //accept an invitation.
   application.conversations.get(event.conversation.id).join();
   //decline the invitation.
    application.conversations.get(event.conversation.id).leave();
 });

member:joined

Application listening for member joined events.

Properties:
Name Type Description
member Member

the member that joined the conversation

event NXMEvent

the join event

Source:
Example

listen for member joined events on Application level

 application.on("member:joined",(member, event) => {
   console.log("JOINED", "Joined conversation: " + event.conversation.display_name || event.conversation.name);
 });

sync:progress

Application listening for sync status events.

Properties:
Name Type Description
status.sync_progress number

Percentage of fetched conversations

Source:
Example

listen for changes in the synchronisation progress events on Application level

 application.on("sync:progress",(status) => {
	  console.log(status.sync_progress);
 });

audio:mute:off

Conversation listening for mute off events
A member has unmuted their audio

Properties:
Name Type Description
member Member

the member object linked to this event

event NXMEvent

information about the mute event

Source:
Example

listen for audio mute off events

conversation.on("audio:mute:off", (member, event) => {
 console.log("member that is unmuted ", member);
 console.log(event);
});

audio:mute:on

Conversation listening for mute on events
A Member has muted their audio

Properties:
Name Type Description
member Member

the Member object linked to this event

event NXMEvent

information about the mute event

Source:
Example

listen for audio mute on events

conversation.on("audio:mute:on", (member, event) => {
 console.log("member that is muted ", member);
 console.log(event);
});

event:delete

Conversation listening for deleted events.

Properties:
Name Type Description
member Member

the Member who deleted an event

event NXMEvent

deleted event: event.id

Source:
Example

get details about the deleted event

conversation.on("event:delete", (member, event) => {
 console.log(event.id);
 console.log(event.body.timestamp.deleted);
});

image

Conversation listening for image events.

Properties:
Name Type Description
sender Member

The sender of the image

image ImageEvent

The image message received

Source:
Example

listen for image events

 conversation.on("image", (sender, image) => {
   console.log(sender,image);
   // Identify if your own imageEvent or someone else's.
   if (image.from !== conversation.me.id){
       displayImages(image);
   }
 });

text

Conversation listening for text events.

Properties:
Name Type Description
sender Member

The sender of the text

text TextEvent

The text message received

Source:
Example

listen for text events

 conversation.on("text",(sender, message) => {
   console.log(sender, message);
   // Identify your own message.
   if (message.from === conversation.me.id){
       renderMyMessages(message)
   } else {
       renderOtherMessages(message)
   }
 });

image:seen

Conversation listening for Members' seen images.

Properties:
Name Type Description
member Member

the member that saw the image

image ImageEvent

the image that was seen

Source:
Example

listen for seen image events

conversation.on("image:seen", (member, image) => {
 console.log(image);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

member:call:status

Conversation listening for Members callStatus changes.

Properties:
Name Type Description
member Member

the Member that has left

Source:
Example

get the callStatus of the member that changed call status

conversation.on("member:call:status", (member) => {
 console.log(member.callStatus);
});

member:invited

Conversation listening for Members being invited.

Properties:
Name Type Description
member Member

the Member that is invited

event NXMEvent

data regarding the receiver of the invitation

Source:
Example

get the name of the invited Member

conversation.on("member:invited", (member, event) => {
 console.log(member.userName + " invited to the conversation");
});

member:joined

Conversation listening for new Members.

Properties:
Name Type Description
member Member

the Member that joined

event NXMEvent

the join event

Source:
Example

get the name of the new Member

conversation.on("member:joined", (member, event) => {
 console.log(event.id)
 console.log(member.userName+ " joined the conversation");
});

member:left

Conversation listening for Members leaving (kicked or left).

Properties:
Name Type Description
member Member

the Member that has left

event NXMEvent

data regarding the receiver of the invitation

Source:
Example

get the username of the Member that left

conversation.on("member:left", (member , event) => {
 console.log(member.userName + " left");
 console.log(event.body.reason);
});

member:media

Conversation listening for Members media changes (audio,text)

Change in media presence state. They are in the Conversation with text or audio.

Properties:
Name Type Description
member Member

the Member object linked to this event

event NXMEvent

information about media presence state

Properties
Name Type Description
body.audio boolean

is audio enabled

Source:
Example

get every Member's media change events

conversation.on("member:media", (member, event) => {
 console.log(event.body.media); //{"audio": true, "audio_settings": {"enabled": true, "muted": false, "earmuffed": false}}
});

message:delivered

Conversation listening for Members delivered messages.

Properties:
Name Type Description
member Member

the member that message was delivered to

message MessageEvent

the message that was delivered

Source:
Example

listen for delivered message events

conversation.on("message:delivered", (member, message) => {
 console.log(message);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

message:rejected

Conversation listening for Members rejected messages.

Properties:
Name Type Description
member Member

the member that message was rejected by

message MessageEvent

the message that was rejected

Source:
Example

listen for rejected message events

conversation.on("message:rejected", (member, message) => {
 console.log(message);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

message:seen

Conversation listening for Members seen messages.

Properties:
Name Type Description
member Member

the member that message was seen by

message MessageEvent

the message that was seen

Source:
Example

listen for seen message events

conversation.on("message:seen", (member, message) => {
 console.log(message);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

message:submitted

Conversation listening for Members submitted messages.

Properties:
Name Type Description
member Member

the member that message was submitted to

message MessageEvent

the message that was submitted

Source:
Example

listen for submitted message events

conversation.on("message:submitted", (member, message) => {
 console.log(message);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

message:undeliverable

Conversation listening for Members undeliverable messages.

Properties:
Name Type Description
member Member

the member that message was undeliverable to

message MessageEvent

the message that was undeliverable

Source:
Example

listen for undeliverable message events

conversation.on("message:undeliverable", (member, message) => {
 console.log(message);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 };
});

text:seen

Conversation listening for Members' seen texts.

Properties:
Name Type Description
member Member

the Member that saw the text

text TextEvent

the text that was seen

Source:
Example

listen for seen text events

conversation.on("text:seen", (member, text) => {
 console.log(text);
 if (conversation.me.id !== member.memberId) {
   console.log(member);
 }
});

text:typing:off

Conversation listening for Members stopped typing.

Properties:
Name Type Description
member Member

the member that stopped typing

event NXMEvent

the stop typing event

Source:
Example

get the display name of the Member that stopped typing

conversation.on("text:typing:off", (member, event) => {
 console.log(member.displayName + " stopped typing...");
});

text:typing:on

Conversation listening for Members typing.

Properties:
Name Type Description
member Member

the member that started typing

event NXMEvent

the start typing event

Source:
Example

get the display name of the Member that is typing

conversation.on("text:typing:on", (member, event) => {
 console.log(member.displayName + " is typing...");
});

media:stream:on

Member listening for audio stream on.

Properties:
Name Type Argument Description
payload.streamIndex number

the index number of this stream

payload.rtc_id number <optional>

the rtc_id / leg_id

payload.remote_member_id string <optional>

the id of the Member the stream belongs to

payload.name string <optional>

the stream's display name

payload.stream MediaStream

the stream that is activated

payload.audio_mute boolean <optional>

if the audio is muted

Source:

disconnect

Client listening for disconnect event.

Source:
Example

Listen for websocket disconnect event

    rtc.on("disconnect", (reason) => {
     console.log("disconnect", reason);
    });

error

Client listening for error event.

Source:
Example

Listen for websocket error event

    rtc.on("error", (error) => {
     console.log("error", error);
    });

ready

Client listening for ready event.

Source:
Example

Listen for websocket ready event

    rtc.on("ready", () => {
     console.log("connection ready");
    });

reconnect

Client listening for reconnect event.

Source:
Example

Listen for websocket reconnect event

    rtc.on("reconnect", (retry_number) => {
     console.log("reconnect", retry_number);
    });

reconnecting

Client listening for reconnecting event.

Source:
Example

Listen for websocket reconnecting event

    rtc.on("reconnecting", (retry_number): void => {
     console.log("reconnecting", retry_number);
    });