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 ip
string ip address of the Media Server
port
string port number of the Media Server
Returns:
- Type
- Promise.<MediaConnectionReport>
Example
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 token
string the JSON Web Token (JWT)
nexmo_api_url
string url of the nexmo api to be called
datacenter
string datacenter of interest
Returns:
- Type
- Promise.<Array.<MediaConnectionReport>>
Example
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 token
string the JSON Web Token (JWT)
options
object configure the connectivityReport
Properties
Name Type Description dcListCallback
function a callback function to edit the list of datacenters before connectivity checks
Returns:
- Type
- Promise.<Report>
Example
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 token
string the user JSON Web Token (JWT)
Returns:
- the application logged in to
- Type
- Promise.<Application>
Example
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
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
rtc.on("disconnect", (reason) => { console.log("disconnect", reason); });
-
error
-
Client listening for error event.
Example
rtc.on("error", (error) => { console.log("error", error); });
-
ready
-
Client listening for ready event.
Example
rtc.on("ready", () => { console.log("connection ready"); });
-
reconnect
-
Client listening for reconnect event.
Example
rtc.on("reconnect", (retry_number) => { console.log("reconnect", retry_number); });
-
reconnecting
-
Client listening for reconnecting event.
Example
rtc.on("reconnecting", (retry_number): void => { console.log("reconnecting", retry_number); });