Skip to navigation

Client (interface)

Web SDK v5 API reference
View as Markdown

Core

Interface that provides API to connect and log in to the Voximplant Cloud.

Methods

addEventListener

addEventListener(eventName: ClientEvent.Disconnected, listener: (event: ClientDisconnected) => void | Promise<void>, options: ListenerOptions): void

Registers a handler for the specified event.

One event can have more than one handler; handlers are executed in order of their registration.

Parameters

ParameterTypeRequirementDescription
eventNameClientEvent.DisconnectedRequiredEvent name
listener(event: ClientDisconnected) => void | Promise<void>RequiredHandler function that is triggered when an event of the specified type occurs
optionsListenerOptionsRequiredObject that specifies characteristics about the event listener

Returns: void

connect

connect(options: ConnectionOptions): Promise<void>

Connects to the Voximplant Cloud.

Returns a promise that is resolved when the connection to the Voximplant Cloud is established.

Parameters

ParameterTypeRequirementDescription
optionsConnectionOptionsRequiredConnect options

Returns: Promise<void>

Throws

One of ConnectionErrors

disconnect

disconnect(): Promise<void>

Disconnects from the Voximplant Cloud.

Returns a promise that is resolved when the connection to the Voximplant Cloud is closed.

Returns: Promise<void>

login

login(options: PasswordLoginOptions): Promise<LoginResult>

Logs in a user with a password to the Voximplant Cloud.

Returns a promise that is resolved to a LoginResult object.

Parameters

ParameterTypeRequirementDescription
optionsPasswordLoginOptionsRequiredOptions to log in with a password

Returns: Promise<LoginResult>

Throws

One of LoginErrors

loginAccessToken

loginAccessToken(options: AccessTokenLoginOptions): Promise<LoginResult>

Logs in a user with an access token to the Voximplant Cloud.

Returns a promise that is resolved to a LoginResult object.

Parameters

ParameterTypeRequirementDescription
optionsAccessTokenLoginOptionsRequiredOptions to log in with an access token

Returns: Promise<LoginResult>

Throws

One of LoginErrors

loginOneTimeKey

loginOneTimeKey(options: OneTimeKeyLoginOptions): Promise<LoginResult>

Logs in a user with a one-time key to the Voximplant Cloud.

Returns a promise that is resolved to a LoginResult object.

Parameters

ParameterTypeRequirementDescription
optionsOneTimeKeyLoginOptionsRequiredOptions to log in with a one-time key

Returns: Promise<LoginResult>

Throws

One of LoginErrors

refreshTokens

refreshTokens(options: RefreshTokenOptions): Promise<LoginTokens>

Performs a refresh of login tokens required for Client.loginAccessToken.

Returns a promise that is resolved to a LoginTokens object.

Parameters

ParameterTypeRequirementDescription
optionsRefreshTokenOptionsRequiredOptions to refresh tokens

Returns: Promise<LoginTokens>

Throws

One of LoginErrors

removeEventListener

removeEventListener(eventName: ClientEvent.Disconnected, listener: (event: ClientDisconnected) => void | Promise<void>): void

Removes a previously registered handler for the specified event.

Parameters

ParameterTypeRequirementDescription
eventNameClientEvent.DisconnectedRequiredEvent name
listener(event: ClientDisconnected) => void | Promise<void>RequiredHandler function to remove from the event target

Returns: void

requestOneTimeKey

requestOneTimeKey(options: RequestOneTimeKeyOptions): Promise<string>

Generates a one-time login key to use in the automated login process.

For additional information please see the guide.

Returns a promise that is resolved to a string that represents the one-time key.

Parameters

ParameterTypeRequirementDescription
optionsRequestOneTimeKeyOptionsRequiredOptions to request a one-time key

Returns: Promise<string>

Throws

One of LoginErrors

Properties

state

Watchable property that allows getting the current client state and observe its changes.