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
call(num: string
| , useVideo: boolean
| , customData: string
, extraHeaders: {[id: string]: string}
):
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
OptionalDeprecated: Please, use CallSettings instead
customData:
string
OptionalDeprecated: Please, use CallSettings instead
extraHeaders:
{[id: string]: string}
OptionalDeprecated: Please, use CallSettings instead
Returns
type:
callConference
callConference(num: string
| , useVideo: boolean
| , customData: string
, extraHeaders: {[id: string]: string}
):
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
OptionalDeprecated: Please, use CallSettings instead
customData:
string
OptionalDeprecated: Please, use CallSettings instead
extraHeaders:
{[id: string]: string}
OptionalDeprecated: Please, use CallSettings instead
Returns
type:
clearSilentLog
clearSilentLog(): void
Clears the logger journal and free some memory.
Returns
type:
void
connect
connect(): Promise<boolean>
Connects to the Voximplant Cloud.
Returns
type:
Promise<boolean>
connected
See [Client.getClientState]
connected(): boolean
Checks if the client is connected to Voximplant Cloud.
Returns
type:
boolean
disconnect
disconnect(): Promise<void>
Disconnects from the Voximplant Cloud.
Returns
type:
Promise<void>
enableSilentLogging
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
getOperatorACDStatus
getOperatorACDStatus(): Promise<OperatorACDStatuses>
Returns the current agent's status for SmartQueue and ACD v1 contact center.
Returns
type:
Promise<OperatorACDStatuses>
getOperatorSQMessagingStatus
getOperatorSQMessagingStatus(): Promise<OperatorACDStatuses>
Returns the current agent's status for SmartQueue messaging.
Returns
type:
Promise<OperatorACDStatuses>
getSilentLog
getSilentLog(): string[]
Gets records from the logger journal.
Returns
type:
string[]
handlePushNotification
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
init(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
config:
Optional
Returns
type:
Promise<Events.SDKReady,string>
isInsertableStreamsSupported
isInsertableStreamsSupported(): boolean
Returns
type:
boolean
isMediaTrackInsertableStreamSupported
isMediaTrackInsertableStreamSupported(): boolean
Returns
type:
boolean
isRTCsupported
isRTCsupported(): boolean
Checks if WebRTC support is available.
Returns
type:
boolean
joinAsSharing
joinAsSharing(num: string
| number
, sendAudio: boolean
, extraHeaders: {[id: string]: string}
):
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: falseWhether to send audio stream (works only for Chrome, Edge)
extraHeaders:
{[id: string]: string}
Optional
Returns
type:
joinAsViewer
joinAsViewer(num: string
| number
, extraHeaders: {[id: string]: string}
):
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
type:
limitAudioCodecs
limitAudioCodecs(codecs: ): Promise<boolean>
Specifies the audio codecs that can be used for calls.
Parameters
codecs:
Returns
type:
Promise<boolean>
limitVideoCodecs
limitVideoCodecs(codecs: ): Promise<boolean>
Specifies the video codecs that can be used for calls.
Parameters
codecs:
Returns
type:
Promise<boolean>
login
login(username: string
, password: string
, options: ): 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:
Optional
Returns
type:
Promise<Events.AuthResult>
loginWithOneTimeKey
loginWithOneTimeKey(username: string
, hash: string
, options: ): 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
username:
string
hash:
string
options:
Optional
Returns
type:
Promise<Events.AuthResult>
loginWithToken
loginWithToken(username: string
, token: string
, options: ): 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:
Optional
Returns
type:
Promise<Events.AuthResult>
off
off(event: , 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
event:
Event name (i.e. Events.SDKReady). See Events
handler:
Function
Optional
Returns
type:
void
on
on(event: , 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:
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
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
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
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
type:
Promise<Events.AuthResult>
screenSharingSupported
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
setConnectionData(gateway: any
, connectionId: any
): void
Parameters
gateway:
any
connectionId:
any
Returns
type:
void
setLoggerCallback
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
setOperatorACDStatus(status: ): Promise<OperatorACDStatuses>
Sets the agent's status for SmartQueue and ACD v1 contact center.
Parameters
status:
Returns
type:
Promise<OperatorACDStatuses>
setOperatorSQMessagingStatus
setOperatorSQMessagingStatus(status: ): Promise<OperatorACDStatuses>
Sets the SmartQueue messaging status.
Parameters
status:
Returns
type:
Promise<OperatorACDStatuses>
setVideoBandwidth
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
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: truemirror:
boolean
OptionalDeprecated
detachCamera:
boolean
OptionalDeprecated
Returns
type:
Promise<MediaRenderer,void>
stopPlayback
stopPlayback(): void
Stops playing ToneScript via WebAudio API.
Returns
type:
void
tokenRefresh
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
OptionalA unique token for the current device
Returns
type:
Promise<Events.RefreshTokenResult>
transferCall
transferCall(call1: , call2: ): 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.
Returns
type:
void
Props
alreadyInitialized
alreadyInitialized: boolean