Constructs new call.

Methods

addEventListener(callevent, handler)

void

Add handler for specific event generated by call.

Example

 VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) {
         var inc = e.call;
         var out = VoxEngine.callPSTN("+13115552368");
         // et cetera
       });
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. Parameter names must start with "X-" to be processed by application

  • parameters: Object (optional)

    Optional custom parameters

callerid()

String

Returns Caller ID for the 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 by hand.

Example

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

    Custom call data to set

Returns
  • String

decline(code, extraHeaders)

void

Reject incoming call (DEPRECATED method - see the reject method)

Parameters
  • code: Number (optional)

    SIP status code

  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with answer message. Parameter names must start with "X-" to be processed by application

detectProgressTone(detect)

void

Enables or disables progress tone detection. Can be used only for outgoing calls. If progress tone is detected, the ToneDetected event is triggered for the call object.

Parameters
  • detect: Boolean

    true/false enable/disable progress tone.

detectVoicemailPrompt(timeout, speechDuration)

void

DEPRECATED || 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. 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

Enables or disables detection of microphone status in the call. If detection is enabled, the event will be triggered.

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. Parameter names must start with "X-" to be processed by application

id()

String

Returns call id

Returns
  • String

incoming()

boolean

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

Returns
  • boolean

number()

String

Returns the 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. Parameter names must start with "X-" to be processed by application

removeEventListener(callevent, handler)

void

Remove event handler for specific event generated by call.

Example

 VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) {
         var inc = e.call;
         var out = VoxEngine.callPSTN("+13115552368");
         inc.answer();
         inc.addEventListener(CallEvents.Connected, function(e) {
            inc.say("Hello, world!");
            inc.addEventListener(CallEvents.PlaybackFinished, firstPlaybackFinished);
            function firstPlaybackFinished() {
              inc.removeEventListener(firstPlaybackFinished); // removes listener for CallEvents.PlaybackFinished
           }
        });
    });
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. Parameter names must start with "X-" to be processed by application. The "X-" parameters will be received by a compatible device on another side. Example: ring({'X-header':'value'}).

say(text, language, ttsoptions)

void

Say some text to the call

If text length exceeds 1500 characters Call.PlaybackFinished event will be triggered with error description.
Parameters
  • text: String

    Message that will be played to the call

  • 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 remote 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

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, so it will stop receiving media from the previous source and will start receiving from this call.

Parameters

sendMessage(text)

void

Send text message during the call

Parameters
  • text: String

    Message text

startEarlyMedia(extraHeaders)

void

Informs call endpoint that early media will be sent before accepting the call. Can be used to play voicemail prompt, music while connecting somewhere and so on. Please note, that unanswered call can be in "early media" state only for a limited amount of time, see VoxEngine session limits for details

Parameters
  • extraHeaders: Object (optional)

    Optional custom parameters (SIP headers) that should be passed with the message. Parameter names must start with "X-" to be processed by application

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. Possible return values: "TERMINATED", "CONNECTED", "PROGRESSING", "ALERTING".

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