new NexmoClient(params)
The parent NexmoClient class.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params | 
            
            object | the settings to initialise the SDK Properties
  | 
        
Fires:
Members
- 
    
<static, readonly> DISCONNECT_REASON :string
 - 
    
    
Enum for NexmoClient disconnection reason.
Type:
- string
 
 
Methods
- 
    
<async> checkMediaConnectivity(ip, port)
 - 
    
    
Return the connection health of a single media server including possible connectionTime in ms.
Parameters:
Name Type Description ipstring ip address of the Media Server
portstring port number of the Media Server
Returns:
- Type
 - Promise.<MediaConnectionReport>
 
Example
Return the connection health of a single media server
rtc.checkMediaConnectivity('ip-address','1').then((response) => { console.log(`IP Address of media server: ${response.ip}`); console.log(`Able to connect: ${response.canConnect}`); console.log(`ConnectionTime in ms: ${resonse.connectionTime}`); }).catch((error) => { console.log(error); }); - 
    
<async> checkMediaServers(token, nexmo_api_url, datacenter)
 - 
    
    
Return a list with the connection health of the media servers for a specific datacenter.
Parameters:
Name Type Description tokenstring the JSON Web Token (JWT)
nexmo_api_urlstring url of the nexmo api to be called
datacenterstring datacenter of interest
Returns:
- Type
 - Promise.<Array.<MediaConnectionReport>>
 
Example
Return a list with the connection health of the media servers
rtc.checkMediaServers('nexmo-api-url','dc').then((responseArray) => { console.log(responseArray); }).catch((error) => { console.log(error); }); - 
    
connect()
 - 
    
    
Connect to the cloud.
 - 
    
<async> connectivityReport(token, options)
 - 
    
    
Get a connectivity report for all Vonage DCs and Media Servers.
Parameters:
Name Type Description tokenstring the JSON Web Token (JWT)
optionsobject configure the connectivityReport
Properties
Name Type Description dcListCallbackfunction a callback function to edit the list of datacenters before connectivity checks
Returns:
- Type
 - Promise.<Report>
 
Example
Get a connectivity report
rtc.connectivityReport(token, { dcListCallback: (dcList) => {...dcList, additionalDc} }).then((report) => { console.log(report); }).catch((error) => { console.log(error); }); - 
    
createSession(token)
 - 
    
    
Create a new Session.
Parameters:
Name Type Description tokenstring the user JSON Web Token (JWT)
Returns:
- the application logged in to
 
- Type
 - Promise.<Application>
 
Example
Create a session and return the Application
rtc.createSession(token).then((application) => { console.log(application); }).catch((error) => { console.log(error); }); - 
    
deleteSession()
 - 
    
    
Delete existing Session.
Returns:
- response with rid and type
 
- Type
 - Promise.<CAPIResponse>
 
Example
Delete existing session
rtc.deleteSession().then((response) => { console.log(response); }).catch((error) => { console.log(error); }); - 
    
disconnect()
 - 
    
    
Disconnect from the cloud.
 
Events
- 
    
disconnect
 - 
    
    
Client listening for disconnect event.
Example
Listen for websocket disconnect event
rtc.on("disconnect", (reason) => { console.log("disconnect", reason); }); - 
    
error
 - 
    
    
Client listening for error event.
Example
Listen for websocket error event
rtc.on("error", (error) => { console.log("error", error); }); - 
    
ready
 - 
    
    
Client listening for ready event.
Example
Listen for websocket ready event
rtc.on("ready", () => { console.log("connection ready"); }); - 
    
reconnect
 - 
    
    
Client listening for reconnect event.
Example
Listen for websocket reconnect event
rtc.on("reconnect", (retry_number) => { console.log("reconnect", retry_number); }); - 
    
reconnecting
 - 
    
    
Client listening for reconnecting event.
Example
Listen for websocket reconnecting event
rtc.on("reconnecting", (retry_number): void => { console.log("reconnecting", retry_number); });