Constructs new call.

Methods

addEventListener(callevent, handler)

void

Add handler for specific event generated by call in specific application state

Parameters
  • callevent: Function

    Event class (i.e. CallEvents.Connected)

  • handler: Function

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

answer(extraHeaders, parameters)

void

Answer incoming call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

  • parameters: Object (optional)

    Optional custom parameters

callerid()

String

Returns Caller ID for call

Returns
  • String

customData(cData)

String

Set or get custom string associated with the particular call (i.e. Call object). Additionally, the customData value could be sent from WEB SDK and then it became the customData() value in the call. Note that if you received some value from WEB SDK, you always could replace it manually.

Example

     Call.customData("some information");  // set or replace the value
Parameters
  • cData: String|undefined

    Custom call data to set. Maximum size is 200 bytes.

Returns
  • String

decline(code, extraHeaders)

void

Reject incoming call

Parameters
  • code: Number (optional)

    SIP status code

  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

detectProgressTone(detect)

void

Enables or disables progress tone detection. The call without an argument is equal to the call with true. Can be used only for outgoing calls. If progress tone is detected, the ToneDetected event will be triggered for the call object. Note that event is triggered only if the CallEvents.Connected event was triggered before.

Parameters
  • detect: Boolean

    true/false enable/disable progress tone.

detectVoicemailPrompt(timeout, speechDuration)

void

Detect voicemail prompt on the call. Please note that this method is based on specific audio signal pattern which isn't always in place, so there is no 100% guarantee that it will detect voicemail in all situations.

Parameters
  • timeout: Number (optional)

    Optional before speech timeout in sec. 5 sec by default

  • speechDuration: Number (optional)

    Optional speech duration in sec. 2 sec by default

detectVoicemailTone(timeout, threshold)

void

Enables or disables Voicemail tone detection. Can be used only for outgoing calls. Tone signal is in the range 500 - 2000 Hz on the call. Right after the method’s call VoxEngine will start to scan a media stream. The scanning will stop after the timeout. If Voicemail tone is detected (or is not detected for some time), the VoicemailToneDetected or VoicemailToneNotDetected event will be triggered for the call object.

Parameters
  • timeout: Number (optional)

    Optional timeout in sec. 20 sec by default

  • threshold: Number (optional)

    Minimal detected tone duration. 100 ms by default

displayName()

String

Returns Display name for the call

Returns
  • String

handleMicStatus(handle)

void

Handle microphone status on the call

Parameters
  • handle: Boolean

    Enable/disable microphone status analysis

handleTones(doHandle)

void

Change DTMF processing mode

Parameters
  • doHandle: Boolean

    If true, each received signal causes ToneReceived event to be dispatched from this Call. Otherwise DTMF signals received from the call, are passed with audio and video data to other calls, that this call is joined to.

hangup(extraHeaders)

void

End the call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with hangup request. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

id()

String

Returns call id

Returns
  • String

incoming()

boolean

Returns true if the call is incoming, false if it was originated from script

Returns
  • boolean

number()

String

Returns dialed number

Returns
  • String

playProgressTone(country)

void

Play country specific progress tone

Note that for this to work properly for call that is not yet connected, you need to invoke Call.startEarlyMedia before using this function
Example

Play Russian progress tone to the call

call.startEarlyMedia();
call.playProgressTone("RU");
Example

Play US progress tone to the call

call.startEarlyMedia();
call.playProgressTone("US");
Parameters
  • country: String (optional)

    2-digit country code. Currently supported values are US, RU

record(params)

void

Start recording call. Both incoming and outgoing streams are being recorded. Emits CallEvents.RecordStarted and CallEvents.RecordStopped events.

Parameters

reject(code, extraHeaders)

void

Reject incoming call

Parameters
  • code: Number (optional)

    SIP status code

  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

removeEventListener(callevent, handler)

void

Remove event handler for specific event generated by call in specific application state

Parameters
  • callevent: Function

    Event class (i.e. CallEvents.Connected)

  • handler: Function (optional)

    Handler function. If not specified, all event listeners are removed

ring(extraHeaders)

void

Send call progress tone to specific call

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with the message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

say(text, language, ttsoptions)

void

Say some text to the call

If text length exceeds 1500 characters Call.PlaybackFinished event is fired with error description.
Parameters
  • text: String

    Message that will be played to the call. SSML markup can be used to control aspects of speech such as pronunciation, volume, pitch, rate, etc.

  • language: String (optional)

    Language and voice to be used. List of all supported languages is available here

  • ttsoptions: VoxEngine.TTSOptions (optional)

    Optional parameters for TTS

sendDigits(digits)

void

Send DTMF digits to the peer

Parameters
  • digits: String

    Any combination of 0-9, *, #, p (pause) symbols

sendInfo(mimeType, body, headers)

void

Send Info (SIP INFO) message inside the call

Parameters
  • mimeType: String

    MIME type of the message

  • body: String

    Message content

  • headers: Object (optional)

    Optional headers to be passed with the message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

sendMediaTo(targetMediaUnit)

void

Start sending media (voice and video) from this call to media unit specified in targetMediaUnit. Each call can send media to any number of other calls, but can receive from just one. So if targetCall was already receiving media from another call, that link would break.

Parameters

sendMessage(text)

void

Send text message during the call

Parameters
  • text: String

    Message text

startEarlyMedia(extraHeaders)

void

Start playing early media to the call. Can be used to play voicemail prompt

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with the message. Custom header names have to begin with the 'X-' prefix. The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the incomingCall event). Example: {'X-header':'value'}

startPlayback(url, loop)

void

Play audio file to the call

Note that for this to work properly for call that is not yet connected, you need to invoke Call.startEarlyMedia before using this function
Parameters
  • url: String

    HTTP/HTTPS url of audio file. Supported formats are: mp3, ogg. Maximum file size if 2 MBytes

  • loop: Boolean (optional)

    If true, playback will be looped.

state()

String

Returns current state of the call

Returns
  • String

stopMediaTo(targetMediaUnit)

void

Stop sending media (voice and video) from this call to media unit specified in targetMediaUnit.

Parameters
  • targetMediaUnit: Call|Conference

    media unit that will not receive media from this call anymore.

stopPlayback()

void

Stop audio playback that was started before by calling startPlayback

toString()

String

Returns human-readable description of the call

Returns
  • String

vad()

Boolean

Returns VAD status

Returns
  • Boolean