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 string '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 RTCStatsConfig

set reporting for stream statistics (Internal event emit)

Properties
Name Type Default Description
emit_events Boolean false

receive rtcstats:report event (deprecated)

emit_rtc_analytics Boolean false

receive rtcstats:analytics event

emit_interval number 1000

interval in ms for rtcstats:report and rtcstats:analytics

remote_collection Boolean true

collect client logs internally

remote_collection_url Boolean 'gollum_url'

url for collecting client logs internally

remote_collection_interval number 5000

interval in ms to collect client logs internally

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 string 'lite'

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

environment string 'production'

development / production environment

iceServers Array.<object>

configure iceServers for RTCPeerConnection

Properties
Name Type Default Description
urls string 'stun:stun.l.google.com:19302'

urls for iceServers

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:*'

enableEventsQueue Boolean true

mechanism to guarantee order of events received during a session

token string

the jwt token for network requests

Source:
Fires:

Members


<static, readonly> DISCONNECT_REASON :string

Enum for NexmoClient disconnection reason.

Type:
  • string
Properties:
Name Type Default Description
ClientDisconnected string ClientDisconnected
TokenExpired string TokenExpired
ConnectionError string ConnectionError
Source:

Methods


connect()

Connect to the cloud.

Source:

disconnect()

Disconnect from the cloud.

Source:

login(token)

Log in to the cloud.

Parameters:
Name Type Description
token string

the login JSON Web Token (JWT)

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

Log in to the Client and return the Application

rtc.login(token).then((application) => {
   console.log(application);
 }).catch((error) => {
   console.log(error);
 });

logout()

Log out from the cloud.

Source:
Returns:
  • response with rid and type
Type
Promise.<CAPIResponse>
Example

Log out of the Client

rtc.logout().then((response) => {
   console.log(response);
 }).catch((error) => {
   console.log(error);
 });

Events


connecting

Client listening for connecting event.

Source:
Example

Listen for websocket connecting event

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

disconnect

Client listening for disconnect event.

Source:
Example

Listen for websocket disconnect event

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

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