Classes

Classes

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

Events


call:status:changed

NXMCall listening for nxmCall status changed events.

Properties:
Name Type Description
nxmCall NXMCall

the actual event

Source:
Example

listen for nxmCall status events

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

NXM-errors

Application listening for joins.

Properties:
Name Type Description
error NexmoClientError
Source:
Examples

listen for errors

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

Update the token on expired-token error

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

member:call

Application listening for calls.

Properties:
Name Type Description
member Member

the member that initiated the nxmCall

nxmCall NXMCall

resolves the nxmCall object

Source:
Example

listen for calls in Application level

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

member:invited

Application listening for invites.

Properties:
Name Type Description
member Member

The invited member

event NXMEvent

The invitation event

Source:
Example

listen for your invites

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 joins.

Properties:
Name Type Description
member Member

the member that joined the conversation

event NXMEvent

the join event

Source:
Example

listen join events in Application level

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

rtcstats:report

Application listening for RTC stats.

Properties:
Name Type Description
MOS number

the calculated MOS score

report Object

the stats report from WebRTC | when the call has ended this is null, see the mos_report for final MOS summary

Conversation Conversation

the conversation the report belongs to

mos_report Object

a report for the MOS values

Properties
Name Type Description
min string

the minimum MOS value during the stream

max string

the maximum MOS value during the stream

last string

the last MOS value during the stream

average string

the average MOS value during the stream

Source:
Example

listening for quality mos score

application.on("rtcstats:report",(mos, report, conversation, mos_report) => {
   console.log("call quality (MOS)", mos);
   if (mos_report) {
     console.log('mos_report', mos_report);
   }
 });

sync:progress

Application listening sync status.

Properties:
Name Type Description
status.sync_progress number

Percentage of fetched conversations

Source:
Example

listening for changes in the synchronisation progress

application.on("sync:progress",(status) => {
	  console.log(data.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:

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:

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 your own imageEvent.
   if (image.from !== conversation.me.id)
   // Identify if the event corresponds to the currently open conversation.
   if (image.cid === conversation.id)
 });

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)
   // Identify if the event corresponds to the currently open conversation.
   if (message.cid === conversation.id)
 });

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", (data, image) => {
 console.log(image);
 // Check if the event belongs to this conversation
 if (image.cid === conversation.id)
 // Get the list of members that have seen this event
 for (let member_id in image.state.seen_by) {
   if (conversation.me.id !== member_id) {
     console.log(conversation.members.get(member_id).name);
   }
 }
});

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.user.name + " 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.user.name+ " 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.user.name + " 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", (from, event) => {
 console.log(from.media.audio_settings.enabled); //true
	console.log(event.body.media); //{"audio_settings": {"enabled": true, "muted": false, "earmuffed": false}}
});

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", (data, text) => {
 console.log(text);
 // Check if the event belongs to this conversation
 if (text.cid === conversation.id)
 // Get the list of members that have seen this event
 for (let member_id in text.state.seen_by) {
   if (conversation.me.id !== member_id) {
     console.log(conversation.members.get(member_id).name);
   }
 }
});

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 username of the member that stopped typing

conversation.on("text:typing:off", (data) => {
 console.log(data.name + " 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 username of the member that is typing

conversation.on("text:typing:on", (data) => {
 console.log(data.name + " 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:

connecting

Connecting event.

Source:
Example

Listen to websocket connecting event

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

disconnect

Disconnect event.

Source:
Example

Listen to websocket disconnect event

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

error

Error event.

Source:
Example

Listen to websocket error event

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

ready

Ready event.

Source:
Example

Listen to websocket ready event

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

reconnect

Reconnect event.

Source:
Example

Listen to websocket reconnect event

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

reconnecting

Reconnecting event.

Source:
Example

Listen to websocket reconnecting event

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