Class: NexmoClient

NexmoClient


new NexmoClient(params)

The parent NexmoClient class.

Parameters:
Name Type Description
params object

the settings to initialise the SDK

Properties
Name Type Default Description
debug Boolean 'silent'

set mode to 'debug', 'info', 'warn', or 'error' for customized logging levels in the console

url string 'nexmo_ws_url'

Nexmo Conversation Websocket url, default is wss://ws.nexmo.com (wss://ws-us-1.nexmo.com for WDC, wss://ws-us-2.nexmo.com for DAL, wss://ws-eu-1.nexmo.com for LON, wss://ws-sg-1.nexmo.com for SNG)

nexmo_api_url string Nexmo

Conversation Api url, default is https://api.nexmo.com (https://api-us-1.nexmo.com for WDC, https://api-us-2.nexmo.com for DAL, https://api-eu-1.nexmo.com for LON, https://api-sg-1.nexmo.com for SNG)

ips_url string 'ips_url'

Nexmo IPS url for image upload, default is https://api.nexmo.com/v1/image (https://api-us-1.nexmo.com/v1/image for WDC, https://api-us-2.nexmo.com/v1/image for DAL, https://api-eu-1.nexmo.com/v1/image for LON, https://api-sg-1.nexmo.com/v1/image for SNG)

path string '/rtc'

Nexmo Conversation Websocket url path suffix

rtcstats object

set reporting for stream statistics (Websocket or internal event emit)

Properties
Name Type Default Description
ws_url string

endpoint (websocket) to send rtc stats.

emit_events Boolean false

receive rtcstats:report event

socket_io object

configure socket.io

Properties
Name Type Default Description
forceNew Boolean true

configure socket.io forceNew attribute

autoConnect Boolean true

socket.io autoConnect attribute

reconnection Boolean true

socket.io reconnection attribute

reconnectionAttempts number 5

socket.io reconnectionAttempts attribute

transports Array.<string> 'websocket'

socket.io transports protocols

sync Array.<string> 'lite'

{'lite' || 'full' || 'none'} after a successful login, synchronise conversations, include events or nothing

environment string 'production'

development / production environment

iceServers object [{'stun:stun.l.google.com:19302'}

iceServers for RTCPeerConnection

callstats object

configure callstats.io integration

Properties
Name Type Default Description
enabled Boolean false
AppID string

your callstats AppID

AppSecret string

your callstats AppSecret

log_reporter object

configure log reports for bugsnag tool

Properties
Name Type Default Description
enabled Boolean true
bugsnag_key string

your bugsnag api key / defaults to Nexmo api key

conversations_page_config object

configure paginated requests for conversations

Properties
Name Type Default Description
page_size number 10

the number of resources returned in a single request list

order string asc

'asc' or 'desc' ordering of resources (usually based on creation time)

cursor string

cursor parameter to access the next or previous page of a data set

events_page_config object

configure paginated requests for events

Properties
Name Type Default Description
page_size number 10

the number of resources returned in a single request list

order string asc

'asc' or 'desc' ordering of resources (usually based on creation time)

event_type string

the type of event used to filter event requests. Supports wildcard options with :* eg. 'members:*'

token string

the jwt token for network requests

iceGatherOnlyOneCandidate string false

the flag for gathering one candidate or multiple in rtc ice gathering process

Source:
Fires:

Methods


connect()

Connect from the cloud.

Source:

disconnect()

Disconnect from the cloud.

Source:

login(token)

Login to the cloud.

Parameters:
Name Type Description
token string

the login token

Source:
Returns:
  • the application we logged in
Type
Promise.<Application>

logout()

logout from the cloud.

Source:

Events


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);
    });