SIGN UP

Call

Methods

active

active(): boolean

Returns 'true' if a call is active, otherwise returns 'false'. A single call (either inbound or outbound) is active by default, all other calls are inactive and should be activated via the setActive method. Only the active call sends and receives an audio/video stream.

Returns

  • Return:

    boolean

answer

answer(customData: string, extraHeaders: Object, useVideo: VideoFlags): void

Answer the incoming call. There are two methods for an incoming call: answer and decline. Voice can be sended only after the answer method call.

Parameters

  • customData:

    string
    Optional

    Set custom string associated with call session. It can be later obtained from Call History using HTTP API, see the custom_data field in result. Custom data can be retrieved on the part of Voxengine via the customData method. Maximum size is 200 bytes.

  • extraHeaders:

    Object
    Optional

    Optional custom parameters (SIP headers) that are sent to another participant after accepting an incoming call. Header names have to begin with the 'X-' prefix. The "X-" headers could be handled only by SIP phones/devices.

  • useVideo:

    VideoFlags
    Optional

    A set of flags defining if sending and receiving video is allowed.

Returns

  • Return:

    void

decline

decline(extraHeaders: Object): void

Reject incoming call on all devices, where this user logged in.

Parameters

  • extraHeaders:

    Object
    Optional

    Optional custom parameters (SIP headers) that should be sent after rejecting incoming call. Parameter names must start with "X-" to be processed by application

Returns

  • Return:

    void

displayName

displayName(): string

Returns display name, i.e. a name of the calling user, that will be displayed to the called user. Normally it's a human-readable version of CallerID, e.g. a person's name.

Returns

  • Return:

    string

getCallDuration

getCallDuration(): number

Get the call duration

Returns

  • Return:

    number

getEndpoints

getEndpoints(): Endpoint[]

Get all current Endpoints in the call.

Returns

hangup

hangup(extraHeaders: Object): void

Hangup call

Parameters

  • extraHeaders:

    Object
    Optional

    Optional custom parameters (SIP headers) that should be sent after disconnecting/cancelling call. Parameter names must start with "X-" to be processed by application

Returns

  • Return:

    void

headers

headers(): Object

Returns headers

Returns

  • Return:

    Object

id

id(): string

Returns call id

Returns

  • Return:

    string

muteMicrophone

muteMicrophone(): void

Mute microphone

Returns

  • Return:

    void

mutePlayback

mutePlayback(): void

Mute sound

Returns

  • Return:

    void

number

number(): string

Returns dialed number or caller id

Returns

  • Return:

    string

off

off(event: CallEvents, handler: Function): void

Remove 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 hangler argument.

Parameters

Returns

  • Return:

    void

on

on(event: CallEvents, handler: Function): void

Register 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 off method to delete a handler.

Parameters

Returns

  • Return:

    void

reject

reject(extraHeaders: Object): void

Reject incoming call on the part of Web SDK. If a call is initiated from the PSTN, the network will receive "reject" command; in case of a call from another Web SDK client, it will receive the CallEvents.Failed event with the 603 code.

Parameters

  • extraHeaders:

    Object
    Optional

    Optional custom parameters (SIP headers) that should be sent after rejecting incoming call. Parameter names must start with "X-" to be processed by application

Returns

  • Return:

    void

sendInfo

sendInfo(mimeType: string, body: string, extraHeaders: Object): void

Send Info (SIP INFO) message inside the call
You can get this message via the Voxengine CallEvents.InfoReceived event in our cloud.
You can get this message in Web SDK on other side via the CallEvents.InfoReceived event; see the similar events for the iOS and Android SDKs.

Parameters

  • body:

    string

    Message content

  • mimeType:

    string

    MIME type of the message, e.g. "text/plain", "multipart/mixed" etc.

  • extraHeaders:

    Object
    Optional

    Optional headers to be passed with the message

Returns

  • Return:

    void

sendMessage

sendMessage(msg: string): void

Send text message. It is a special case of the sendInfo method as it allows to send messages only of "text/plain" type.
You can get this message via the Voxengine CallEvents.MessageReceived event in our cloud.
You can get this message in Web SDK on other side via the CallEvents.MessageReceived event; see the similar events for the iOS and Android SDKs.

Parameters

  • msg:

    string

    Message text

Returns

  • Return:

    void

sendTone

sendTone(key: string): void

Send tone (DTMF). It triggers the CallEvents.ToneReceived event in our cloud.

Parameters

  • key:

    string

    Send tone according to pressed key: 0-9 , * , #

Returns

  • Return:

    void

sendVideo

sendVideo(flag: boolean): Promise<Updated>

Start/stop sending video from a call. In case of a remote participant uses a Web SDK client, it will receive either the EndpointEvents.RemoteMediaAdded or EndpointEvents.RemoteMediaRemoved event accordingly.
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

Returns

setActive

setActive(flag: boolean): Promise<Updated>

The method makes a call active, i.e. change the active flag to 'true'. A single call (either inbound or outbound) is active by default, all other calls are inactive and should be activated.

Parameters

  • flag:

    boolean

Returns

shareScreen

shareScreen(showLocalView: boolean): Promise<Updated>

Enable screen sharing. Works in Chrome and Firefox. For Chrome, custom extension must be created and installed from this template: "https://github.com/voximplant/voximplant-chrome-extension". "matches" section in the extension's "manifest.json" should be set to app website url(s). Browser will ask user for a window or screen to share. Can be called multiple times to share multiple windows.

Parameters

  • showLocalView:

    boolean

    if set to true, a screen sharing preview will be displayed locally in the same way as it's done for video calls. It is false by default. 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.

Returns

state

state(): string

Get the current state of a call.
Possible values are: "ALERTING", "PROGRESSING", "CONNECTED", "ENDED".

Returns

  • Return:

    string

stopSharingScreen

stopSharingScreen(): Promise<Updated>

Stops screen sharing. If 'shareScreen' was called multiple times, this will stop sharing for all windows/screens

Returns

unmuteMicrophone

unmuteMicrophone(): void

Unmute microphone

Returns

  • Return:

    void

unmutePlayback

unmutePlayback(): void

Unmute sound

Returns

  • Return:

    void

Properties

rearangeCodecs

rearangeCodecs: (codecList: CodecSorterUserCodecList, incoming?: boolean) => Promise<CodecSorterUserCodecList>

Callback for manual rearrangement or setup compatible codec list. If will set unknown/unsupported codec - it will be ignored

Example

// example sorting video section to set h264 first
var currentCall = vox.call("exampleUser");
currentCall.rearangeCodecs = function(codecList){
  return new Promise(function(resolve,reject){
    for(var i=0;i{
          if(a.toLowerCase().indexOf("h264")!=-1
           &&a.toLowerCase().indexOf("uc")==-1)
             return -1;
          if(b.toLowerCase().indexOf("h264")!=-1
           &&b.toLowerCase().indexOf("uc")==-1)
             return 1;
          return 0;
        })
      }
    }
    resolve(codecList);
  })
};

Type declaration

(codecList: CodecSorterUserCodecList, incoming?: boolean) => Promise

Parameters

Returns