Class: CallPackage

wsc. CallPackage

A package that enables call applications. An object of the CallPackage class can be created by web applications to manage Call objects. The object also dispatches received messages to corresponding Call objects for handling.

new CallPackage(session, packageType)

Parameters:
Name Type Description
session Object

an instance of session object

packageType String

The name of call package. If not provided, default value is 'call'.

Methods

close()

Hang up all the Package managed calls and release all the resources.

createCall(target, callConfig, errorCallback) → {wsc.Call}

Creates a Call.

Parameters:
Name Type Description
target String

the name of the target

callConfig wsc.CallConfig

an instance of CallConfig object that represents the capabilities of the call

errorCallback

the error callback function for any error occuring during the call

Returns:

an instance of the Call

Type
wsc.Call

getCalls() → {Array}

Gets all the Call objects managed by this package.

Returns:

an array of Call objects managed by this Package.

Type
Array

onMessage(msg)

For extensibility - Processes the received JSON message between client and WebRTC Session Controller server.
Application can override this method to handle the JSON message directly.

Parameters:
Name Type Description
msg Object

the received message

onRehydration(rehydratedData)

For extensibility - Handles the rehydration data.
This function handles the rehydrated data from local storage. It is invoked when the web page is reloaded.
This is an SPI function that can be overridden when the CallPackage object that is exposed by the WebRTC Session Controller JavaScript API is extended.
After the page reloads, an application can use this method to restore the related session object, which is the Call object in the CallPackage.

Parameters:
Name Type Description
rehydratedData

the rehydrated data

prepareCall(session, callConfig, caller, callee)

For extensibility - Builds a wsc.Call and returns it.
This is an SPI function which may be overridden by an extended CallPackage to build and return a custom extended Call object.

Parameters:
Name Type Description
session wsc.Session

The call object uses this Session to send and receive messages.

callConfig wsc.CallConfig

The wsc.CallConfig object to configure the capabilities of the call.

caller String

Caller identity

callee String

Callee identity

Returns:

The call object

putCall(id, call)

For extensibility - Puts a Call object with a key into a session. This is an SPI function that can be overridden by an extension package.

Parameters:
Name Type Description
id String

sub-session id of the call

call wsc.Call

the Call object instance

setTrickleIceMode(mode)

Set client trickle ice mode. The value should be one of "full", "half" and "off".

Parameters:
Name Type Description
mode

the tricile ice mode

Events

onIncomingCall

An event handler which is called when a new call is received. When the event handler is invoked, wsc.Call, wsc.CallConfig, and extensionHeaders, are provided as parameters.

Parameters:
Name Type Description
call wsc.Call

an instance of Call object

remoteCallConfig wsc.CallConfig

an instance of CallConfig object

extHeaders JSON

extension headers.

Example
function onIncomingCall(callObj, remoteCallConfig, extheaders) {
  acceptButton.onclick = function() {
    callObj.accept(callObj.callConfig, null, extheaders);
  }
  declineButton.onclick = function() {
    callObj.decline(null, extheaders);
  }
  //Set related callback functions of call
  callObj.onCallStateChange = function(newState) {...};
  callObj.onMediaStreamEvent= function(mediaStreamEvent, stream) {...};
  call = callObj;
}

onResurrect

An event handler which is called when a Call is rehydrated. When it is invoked, a (wsc.Call) object is provided as parameter.

Parameters:
Name Type Description
call wsc.Call

a Call object instance

Example
callHandler = new wsc.CallPackage(wscSession);
if(callHandler){
  callHandler.onResurrect = onResurrect;
}
function onResurrect(rehydratedCall) {
  // Set callback for call state changed.
  rehydratedCall.onCallStateChange = function(newState) {
    ...
  }
  // Set callback for media state changed.
  rehydratedCall.onMediaStreamEvent= function(mediaStreamEvent, stream) {
    ...
  }
  // Resume the call with setting related callback functions.
  rehydratedCall.resume(onResumeCallSuccess, doCallError);
}
Oracle® Communications WebRTC Session Controller JavaScript API Reference, E55131-03
Copyright © 2013, 2015, Oracle and/or its affiliates. All rights reserved.