Call
Interface that represents a call and provides the API to manage it.
Methods
addEventListener
addEventListener(eventName: , listener: (event: AnyCallEvent) => void | Promise<void>
, options: ): 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
eventName:
Event name
listener:
(event: AnyCallEvent) => void | Promise<void>
Handler function that is triggered when an event of the specified type occurs
options:
Object that specifies characteristics about the event listener
Returns
type:
void
addStream
addStream(stream: ): Promise<void>
Starts sending an audio or video stream to the call.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is in CallState.Failed, CallState.Disconnecting, or CallState.Disconnected state
- StreamTypeMismatchError if the stream is of StreamType.ScreenVideo type
- CallOnHoldError if the call is currently on hold
- InactiveStreamError if the stream is not active
- StreamUpdateFailedError if the operation has failed
Parameters
stream:
Audio or video stream
Returns
type:
Promise<void>
answer
answer(settings: ): Promise<void>
Answers an incoming call.
Returns a promise that is resolved if the call connection process has started successfully. A resolved promise does not mean that the call is connected. You should subscribe to CallEvent.Connected to be notified that the call is established.
Throws:
- CallWrongDirectionError if the method is called for an outgoing call
- CallWrongStateError if the call is in a state different from CallState.Created or CallState.Reconnecting
- CallInternalError if the operation has failed
Parameters
settings:
OptionalCall settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc.
Returns
type:
Promise<void>
hangup
hangup(headers: Record<string, string>
): void
Terminates the call.
Parameters
headers:
Record<string, string>
OptionalOptional set of headers to be sent. Names should begin with “X-” to be processed by the SDK.
Returns
type:
void
hold
hold(enable: boolean
): Promise<void>
Holds or unholds the call.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is not in the CallState.Connected
- CallOnHoldError on the attempt to hold the call that is already on hold
- CallNotOnHoldError on the attempt to resume the call that is currently not on hold
- CallInternalError if the operation has failed
Parameters
enable:
boolean
Whether to hold or unhold the call
Returns
type:
Promise<void>
muteMicrophone
muteMicrophone(): void
Mutes the audio in the call.
Returns
type:
void
reject
reject(rejectMode: , headers: Record<string, string>
): void
Rejects an incoming call.
Parameters
rejectMode:
Call rejection mode
headers:
Record<string, string>
OptionalOptional set of headers to be sent. Names should begin with “X-” to be processed by the SDK.
Returns
type:
void
Throws
CallWrongDirectionError if the method is called for the outgoing call
removeEventListener
removeEventListener(eventName: , listener: (event: AnyCallEvent) => void | Promise<void>
): void
Removes a previously registered handler for the specified event.
Parameters
eventName:
Event name
listener:
(event: AnyCallEvent) => void | Promise<void>
Handler function to remove from the event target
Returns
type:
void
removeStream
removeStream(stream: ): Promise<void>
Stops sending audio or video stream to the call.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is in CallState.Failed, CallState.Disconnecting, or CallState.Disconnected state
- StreamTypeMismatchError if the stream is of StreamType.ScreenAudio or StreamType.ScreenVideo type
- CallOnHoldError if the call is currently on hold
- StreamUpdateFailedError if the operation has failed
Parameters
stream:
Returns
type:
Promise<void>
replaceStream
replaceStream(stream: , oldStream: ): Promise<void>
Replaces the local audio or video stream that is currently being sent to the call with another local audio or video stream.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is in CallState.Failed, CallState.Disconnecting, or CallState.Disconnected state
- StreamTypeMismatchError if the stream is of StreamType.ScreenAudio or StreamType.ScreenVideo type
- StreamUpdateFailedError if the operation has failed
Parameters
stream:
New local stream
oldStream:
OptionalStream to replace
Returns
type:
Promise<void>
sendDTMF
sendDTMF(tones: string
): void
Sends DTMF(s) within the call.
Parameters
tones:
string
DTMF(s)
Returns
type:
void
Throws
InvalidArgumentsError if the tones parameter is an empty string
sendInfo
sendInfo(mimeType: ${string}/${string}
, body: string
, headers: Record<string, string>
): void
Sends an INFO message within the call.
Parameters
mimeType:
${string}/${string}
MIME type of the info
body:
string
Custom string data
headers:
Record<string, string>
OptionalOptional set of headers to be sent with the message. Names should begin with “X-” to be processed by the SDK.
Returns
type:
void
Throws
InvalidMimeTypeError if the provided mimeType is in an invalid format
sendMessage
sendMessage(message: string
): void
Sends a message within the call.
Implemented atop of SIP INFO for communication between the call endpoint and the Voximplant Cloud, and is separated from Voximplant messaging API.
Parameters
message:
string
Message text
Returns
type:
void
start
start(): Promise<void>
Starts an outgoing call.
Returns a promise that is resolved if the call connection process has started successfully. A resolved promise does not mean that the call is connected. You should subscribe to CallEvent.Connected to be notified that the call is established.
Throws:
- CallWrongDirectionError if the method is called for an incoming call
- CallWrongStateError if the call is in a state different from CallState.Created or CallState.Reconnecting
Returns
type:
Promise<void>
startScreenSharing
startScreenSharing(stream: ): Promise<void>
Starts sending a screen sharing stream to the call.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is not in the CallState.Connected
- CallOnHoldError if the call is currently on hold
- InactiveStreamError if the stream is not active
- StreamUpdateFailedError if the operation has failed or the screen sharing is already sending to the call
Parameters
stream:
Array of screen sharing streams
Returns
type:
Promise<void>
stopScreenSharing
stopScreenSharing(): Promise<void>
Stops sending a screen sharing stream to the call.
Returns a promise that is resolved when the operation is completed.
Throws:
- CallWrongStateError if the call is not in the CallState.Connected
- CallOnHoldError if the call is currently on hold
- StreamUpdateFailedError if the operation has failed or the screen sharing is not currently being sent
Returns
type:
Promise<void>
toggleMicrophone
toggleMicrophone(): boolean
Toggles the audio mute status in the call.
Returns
type:
boolean
unmuteMicrophone
unmuteMicrophone(): void
Unmutes the audio in the call.
Returns
type:
void
Props
destination
destination: string
Destination that the call has been created with.
duration
duration: number
Call duration in seconds.
hasScreenSharing
hasScreenSharing: ReadonlyWatchable<boolean>
Watchable property that allows getting the screen sharing sending status and observing its changes.
id
id: string
Call id.
isMicrophoneMuted
isMicrophoneMuted: ReadonlyWatchable<boolean>
Watchable property that allows getting the audio mute status and observing its changes.
isOnHold
isOnHold: ReadonlyWatchable<boolean>
Watchable property that allows getting whether the call is on hold.
isVideoEnabled
isVideoEnabled: ReadonlyWatchable<boolean>
Watchable property that indicates whether the video is enabled and allows observing its changes.
localStreams
localStreams: ReadonlyWatchable<Set<LocalStream>>
Watchable property that allows getting the array of the local audio and video streams that are currently being sent.
remoteDisplayName
remoteDisplayName: ReadonlyWatchable<null | string>
Watchable property that allows getting the call participant user display name and observing its changes.
Null for outgoing calls until the CallEvent.Connected event is triggered.
remoteSipUri
remoteSipUri: ReadonlyWatchable<null | string>
Watchable property that allows getting the call participant sip URI and observing its changes.
Null for outgoing calls until the CallEvent.Connected event is triggered.
remoteStreams
remoteStreams: Watchable property that allows getting the array of the remote audio and video streams that are currently being received.
state
state: Watchable property that allows getting the current call state and observing its changes.