Index


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

Class Summary
Constructor Attributes Constructor Name and Description
 
wsc.CallPackage(session)
Method Summary
Method Attributes Method Name and Description
 
Hang up all the Package managed calls and release all the resources.
 
createCall(target, callConfig, errorCallback)
Creates a Call.
 
Gets all the Call objects managed by this package.
 
prepareCall(session, callConfig, caller, callee)
For extensibility - Builds a wsc.Call and returns it.
 
putCall(id, call)
For extensibility - Puts a Call object with a key into a session.
Event Summary
Event Attributes Event Name and Description
 
onIncomingCall(call, remoteCallConfig, extHeaders)
An event handler which is called when a new call is received.
 
onMessage(msg)
For extensibility - Processes the received message
This function handles the received messages, and dispatches messages to corresponding Call objects.
 
onRehydration(rehydratedData)
For extensibility - Handles the rehydration data.
 
An event handler which is called when a Call is rehydrated.
Class Detail
wsc.CallPackage(session)
Parameters:
{Object} session
an instance of session object
Method Detail
close()
Hang up all the Package managed calls and release all the resources.

{wsc.Call} createCall(target, callConfig, errorCallback)
Creates a Call.
Parameters:
{String} target
the name of the target
{wsc.CallConfig} 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:
{wsc.Call} an instance of the Call

{array} getCalls()
Gets all the Call objects managed by this package.
Returns:
{array} an array of Call objects managed by this Package.

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:
{wsc.Session} session
The call object uses this Session to send and receive messages.
{wsc.CallConfig} callConfig
The wsc.CallConfig object to configure the capabilities of the call.
{String} caller
Caller identity
{String} callee
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 which can be overridden by an extension package.
Parameters:
{String} id
sub-session id of the call
{wsc.Call} call
the Call object instance
Event Detail
onIncomingCall(call, remoteCallConfig, extHeaders)
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.
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;
}
Parameters:
{wsc.Call} call
an instance of Call object
{wsc.CallConfig} remoteCallConfig
an instance of CallConfig object
{Object} extHeaders
extension headers. These are extracted from the JSON message if they exist.
For example, An extHeaders entry like this, {'customerKey1':'value1','customerKey2':'value2'}
is extracted from a message and formatted like this :
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

onMessage(msg)
For extensibility - Processes the received message
This function handles the received messages, and dispatches messages to corresponding Call objects. This is an SPI function which may be overridden when the CallPackage object exposed by the WebRTC Session Controller JavaScript API is extended.
Parameters:
{Object} msg
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 which can be overridden when the CallPackage object 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:
rehydratedData
the rehydrated data

onResurrect(call)
An event handler which is called when a Call is rehydrated. When it is invoked, a (wsc.Call) object is provided as parameter.
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);
}
Parameters:
{wsc.Call} call
a Call object instance

Copyright © 2005, 2013, Oracle and/or its affiliates. All rights reserved.