Rate this page:

Client

The Client class is used to control platform functions. Cannot be instantiated directly (singleton), so use the getInstance method to get the class instance.

Methods

call

Copy URL
call(num: 

string

|

CallSettings

,
useVideo:

boolean

|

VideoFlags

,
customData:

string

,
extraHeaders:

{[id: string]: string}

):

Call

Creates a call.This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.

Parameters

  • num:

    string

    The number to call or CallSettings. For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario

  • useVideo:

    boolean

    Optional

    Deprecated: Please, use CallSettings instead

  • customData:

    string

    Optional

    Deprecated: Please, use CallSettings instead

  • extraHeaders:

    {[id: string]: string}

    Optional

    Deprecated: Please, use CallSettings instead

Returns

callConference

Copy URL
callConference(num: 

string

|

CallSettings

,
useVideo:

boolean

|

VideoFlags

,
customData:

string

,
extraHeaders:

{[id: string]: string}

):

Call

Creates a call to a dedicated conference without a proxy session. For details see the video conferencing guide.This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.

Parameters

  • num:

    string

    The number to call or CallSettings. For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario

  • useVideo:

    boolean

    Optional

    Deprecated: Please, use CallSettings instead

  • customData:

    string

    Optional

    Deprecated: Please, use CallSettings instead

  • extraHeaders:

    {[id: string]: string}

    Optional

    Deprecated: Please, use CallSettings instead

Returns

clearSilentLog

Copy URL
clearSilentLog(): 

void

Clears the logger journal and free some memory.

Returns

  • type:

    void

config

Copy URL
config(): 

Config

Gets the current config.

Returns

connect

Copy URL
connect(): 

Promise<boolean>

Connects to the Voximplant Cloud.

Returns

  • type:

    Promise<boolean>

connected

Deprecated
Copy URL
connected(): 

boolean

Checks if the client is connected to Voximplant Cloud.

Returns

  • type:

    boolean

disconnect

Copy URL
disconnect(): 

Promise<void>

Disconnects from the Voximplant Cloud.

Returns

  • type:

    Promise<void>

enableSilentLogging

Copy URL
enableSilentLogging(flag: 

boolean

):

void

Sets the state of the silent logging inside SDK (it is disabled by default). When it is enabled, the WebSDK saves all logger messages into the logger until you disable it.Note that enabling of the silent logging automatically clears all existed logger records before the start.

You can get current logger by the getSilentLog function and clean it by the clearSilentLog function.

Parameters

  • flag:

    boolean

Returns

  • type:

    void

getClientState

Copy URL
getClientState(): 

ClientState

Gets current client state

Returns

getOperatorACDStatus

Copy URL
getOperatorACDStatus(): 

Promise<OperatorACDStatuses>

Returns the current agent's status for SmartQueue and ACD v1 contact center.

Returns

getOperatorSQMessagingStatus

Copy URL
getOperatorSQMessagingStatus(): 

Promise<OperatorACDStatuses>

Returns the current agent's status for SmartQueue messaging.

Returns

getSilentLog

Copy URL
getSilentLog(): 

string[]

Gets records from the logger journal.

Returns

  • type:

    string[]

handlePushNotification

Copy URL
handlePushNotification(message: 

any

):

Promise<void>

Handles push notification

Parameters

  • message:

    any

    Push notification that comes from the firebase.messaging().setBackgroundMessageHandler callback inside a service worker

Returns

  • type:

    Promise<void>

init

Copy URL
init(config: 

Config

):

Promise<Events.SDKReady,string>

Initializes the SDK. The Events.SDKReady event is dispatched after successful SDK initialization. SDK cannot be used until it is initialized.

Parameters

Returns

isInsertableStreamsSupported

Copy URL
isInsertableStreamsSupported(): 

boolean

Returns

  • type:

    boolean

isMediaTrackInsertableStreamSupported

Copy URL
isMediaTrackInsertableStreamSupported(): 

boolean

Returns

  • type:

    boolean

isRTCsupported

Copy URL
isRTCsupported(): 

boolean

Checks if WebRTC support is available.

Returns

  • type:

    boolean

joinAsSharing

Copy URL
joinAsSharing(num: 

string

|

number

,
sendAudio:

boolean

,
extraHeaders:

{[id: string]: string}

):

SharingCall

Calls the specified conference as a separate screen sharing participant.This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.

Parameters

  • num:

    string

    The conference room ID. Use different room IDs for different conference rooms. You can launch different scenarios depending on this parameter by specifying this value as a routing rule pattern.

  • sendAudio:

    boolean

    Defaults on:  false

    Whether to send audio stream (works only for Chrome, Edge)

  • extraHeaders:

    {[id: string]: string}

    Optional

Returns

joinAsViewer

Copy URL
joinAsViewer(num: 

string

|

number

,
extraHeaders:

{[id: string]: string}

):

ViewerCall

Calls the specified conference as viewer participant only for receiving audio/video.This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.

Parameters

  • num:

    string

    The conference room number or ID

  • extraHeaders:

    {[id: string]: string}

    Optional

Returns

limitAudioCodecs

Copy URL
limitAudioCodecs(codecs: 

CodecDescription[]

):

Promise<boolean>

Specifies the audio codecs that can be used for calls.

Parameters

Returns

  • type:

    Promise<boolean>

limitVideoCodecs

Copy URL
limitVideoCodecs(codecs: 

CodecDescription[]

):

Promise<boolean>

Specifies the video codecs that can be used for calls.

Parameters

Returns

  • type:

    Promise<boolean>

login

Copy URL
login(username: 

string

,
password:

string

,
options:

LoginOptions

):

Promise<Events.AuthResult>

Logs in to an application. The method triggers the Events.AuthResult event.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"

  • password:

    string

    The user's password

  • options:

    LoginOptions

    Optional

Returns

loginWithOneTimeKey

Copy URL
loginWithOneTimeKey(username: 

string

,
hash:

string

,
options:

LoginOptions

):

Promise<Events.AuthResult>

Logs in to an application via the 'onetimekey' auth method. Hash should be calculated with the key from the triggered Events.AuthResult event.Please read the article about the authorization with one-time key.

Parameters

Returns

loginWithToken

Copy URL
loginWithToken(username: 

string

,
token:

string

,
options:

LoginOptions

):

Promise<Events.AuthResult>

Logs in to an application via an accessToken. The method triggers the Events.AuthResult event.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com"

  • token:

    string

  • options:

    LoginOptions

    Optional

Returns

off

Copy URL
off(event: 

Events

,
handler:

Function

):

void

Removes a handler for the specified event. The method is a shorter equivalent for removeEventListener. If a number of events has the same function as a handler, the method can be called multiple times with the same handler argument.

Parameters

Returns

  • type:

    void

on

Copy URL
on(event: 

Events

,
handler:

Function

,
options:

EventListenerOption

):

void

Registers a handler for the specified event. The method is a shorter equivalent for addEventListener. One event can have more than one handler; handlers are executed in order of registration. Use the Client.off method to delete a handler.

Parameters

  • event:

    Events

    Event name (i.e. Events.SDKReady). See Events

  • handler:

    Function

    Handler function. A single parameter is passed - object with event information

  • options:

    EventListenerOption

    Optional

Returns

  • type:

    void

playToneScript

Copy URL
playToneScript(script: 

string

,
loop:

boolean

):

void

Plays a ToneScript via WebAudio API.

Parameters

  • script:

    string

    Tonescript string

  • loop:

    boolean

    Defaults on:  false

Returns

  • type:

    void

registerForPushNotifications

Copy URL
registerForPushNotifications(token: 

string

):

Promise<void>

Registers for push notifications. Application receive push notifications from Voximplant Server after first login.

Parameters

  • token:

    string

    FCM registration token that can be retrieved by calling firebase.messaging().getToken() inside a service worker

Returns

  • type:

    Promise<void>

requestOneTimeLoginKey

Copy URL
requestOneTimeLoginKey(username: 

string

):

Promise<Events.AuthResult>

Requests a key for the 'onetimekey' auth method. Server sends the key in the Events.AuthResult event with the code 302.Please read the article about the authorization with one-time key.

Parameters

  • username:

    string

Returns

screenSharingSupported

Copy URL
screenSharingSupported(): 

Promise<boolean>

Returns promise that is resolved with a boolean flag. The boolean flag. is set to 'true' if screen sharing is supported. Promise is rejected in case of an internal error.

Returns

  • type:

    Promise<boolean>

setConnectionData

Copy URL
setConnectionData(gateway: 

any

,
connectionId:

any

):

void

Parameters

  • gateway:

    any

  • connectionId:

    any

Returns

  • type:

    void

setLoggerCallback

Copy URL
setLoggerCallback(callback: 

Function

):

void

Sets outer logging callback.The method allows integrating logging pipeline of the WebSDK into the own logger i.e. the method call sends all events to the function. IMPORTANT: the callback strictly ignores Loglevel settings of the WebSDK.

Parameters

  • callback:

    Function

Returns

  • type:

    void

setOperatorACDStatus

Copy URL
setOperatorACDStatus(status: 

OperatorACDStatuses

):

Promise<OperatorACDStatuses>

Sets the agent's status for SmartQueue and ACD v1 contact center.

Parameters

Returns

setOperatorSQMessagingStatus

Copy URL
setOperatorSQMessagingStatus(status: 

OperatorACDStatuses

):

Promise<OperatorACDStatuses>

Sets the SmartQueue messaging status.

Parameters

Returns

setVideoBandwidth

Copy URL
setVideoBandwidth(bandwidth: 

number

):

void

Sets the bandwidth limit for video calls. Currently supported by Chrome/Chromium. (WebRTC mode only). The limit is to be applied for the next call.

Parameters

  • bandwidth:

    number

    Bandwidth limit in kilobits per second (kbps)

Returns

  • type:

    void

showLocalVideo

Copy URL
showLocalVideo(flag: 

boolean

,
mirror:

boolean

,
detachCamera:

boolean

):

Promise<MediaRenderer,void>

Shows/hides the local video. IMPORTANT: Safari browser for iOS requires a user interface for playing video during a call. It should be interactive element like an HTML "button" with "onclick" handler that calls "play" method on the "video" HTML element.

Parameters

  • flag:

    boolean

    Defaults on:  true
  • mirror:

    boolean

    Optional

    Deprecated

  • detachCamera:

    boolean

    Optional

    Deprecated

Returns

stopPlayback

Copy URL
stopPlayback(): 

void

Stops playing ToneScript via WebAudio API.

Returns

  • type:

    void

tokenRefresh

Copy URL
tokenRefresh(username: 

string

,
refreshToken:

string

,
deviceToken:

string

):

Promise<Events.RefreshTokenResult>

Refreshes the expired access token.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

  • refreshToken:

    string

  • deviceToken:

    string

    Optional

    A unique token for the current device

Returns

transferCall

Copy URL
transferCall(call1: 

Call

,
call2:

Call

):

void

Transfers a call. Depending on the result, CallEvents.TransferComplete or CallEvents.TransferFailed event is dispatched.This method can throw the 1003 error if the client is not connected to the Voximplant Cloud or the 1004 error if the client is not authorized.

Parameters

  • call1:

    Call

    The call to transfer

  • call2:

    Call

    The destination call where the call1 needs to be transferred

Returns

  • type:

    void

Props

alreadyInitialized

Copy URL
alreadyInitialized: 

boolean