Classes
- AuthHandler
- Call
- CallConfig
- CallPackage
- CapabilityExchange
- CapabilityPackage
- Chat
- ChatPackage
- DataReceiver
- DataSender
- DataTransfer
- ExtensibleSession
- FileTransfer
- FileTransferPackage
- FlashCall
- FlashCallPackage
- Map
- Message
- MessageAlertPackage
- MessageCounts
- MessageSummary
- Messaging
- Messaging
- MessagingPackage
- Notification
- Session
- Subscription
Namespaces
Events
-
refresh
-
The callback function to handle the authentication event.
Parameters:
Name Type Description authType
String the authentication type.
authHeaders
Object the headers that used for the authentication. For both wsc.AUTHTYPE.TURN and wsc.AUTHTYPE.SERVICE, there is not headers and it is passed as null.
Returns:
if authType is wsc.AUTHTYPE.SERVICE, then {"username": yourUsername, "password": yourPassword} should be returned; if authType is wsc.AUTHTYPE.TURN, then {"iceServers": [iceServer1, iceServer2, ...]} should be returned. Here are two examples. Return {"username": "admin", "password": "admin"} for wsc.AUTHTYPE.SERVICE. Return {"iceServers": [{"url":"turn:10.182.13.232:3478", "credential":"sips", "username":"admin"}]} for wsc.AUTHTYPE.TURN.
- Type
- Object
-
onCallStateChange
-
Event handler called when the call state is changed.
Parameters:
Name Type Description callState
wsc.CallState The CallState object indicating the latest call state
extHeaders
JSON extension headers
Example
function onCallStateChange(callState, extHeaders) { showResults('Call state changed:' + callState.state); if (callState.state == wsc.CALLSTATE.ESTABLISHED) { // show the call // display extention headers } }
-
onDataTransfer
-
Event handler that is called when a DataTransfer object is created. The application should set this callback function to get the DataTransfer object for a Call's data channel.
For the caller, the application should set it before invoking Call.start().
For the callee, the application should set it when it has obtained the call object in onIncomingCall().Parameters:
Name Type Description dataTransfer
wsc.DataTransfer The DataTransfer object created for the application
Example
function onDataTransfer(dataTransfer) { console.log("Data transfer call back is called."); //keep the reference of dataTransfer, and initial the callback functions of dataTransfer. myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; }
-
onMediaStreamEvent
-
Event handler called when media state is changed.
Parameters:
Name Type Description mediaStreamEvent
wsc.MEDIASTREAMEVENT the media stream event defined in client SDK.
mediaStream
RTCMediaStream the media stream
Example
function onMediaStreamEvent(mediaStreamEvent, stream) { var rurl = URL.createObjectURL(stream); var audioTracks = null; var videoTracks = null; if(stream.audioTracks) { // Old version audioTracks = stream.audioTracks; videoTracks = stream.videoTracks; } else { // New version audioTracks = stream.getAudioTracks(); videoTracks = stream.getVideoTracks(); } if (mediaStreamEvent == wsc.MEDIASTREAMEVENT.LOCAL_STREAM_ADDED) { if (videoTracks.length > 0) { //Local video stream is added. selfView.src = rurl; } else if (audioTracks.length > 0) { //Local audio stream is added. selfAudio.src = rurl; } } else if (mediaStreamEvent == wsc.MEDIASTREAMEVENT.REMOTE_STREAM_ADDED) { if (videoTracks.length > 0) { // Remote video stream is added. remoteView.src = rurl; } else if (audioTracks.length > 0) { // Remote audio stream is added. remoteAudio.src = rurl; } } }
-
onMessage
-
For extensibility - Processes the received JSON message between client and WebRTC Session Controller server.
Applications can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
wsc.Message The message received
-
onUpdate
-
Event handler called when there is an update request for an established call.
Parameters:
Name Type Description callConfig
wsc.CallConfig The new CallConfig object used to update the call
extHeaders
JSON extension headers
-
onIncomingCall
-
An event handler which is called when a new call is received. When 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 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); }
-
onError
-
Event handler that is called when an error message is received, for example, the enquiry target is not reachable, or the enquiry request has timed out and so on.
Parameters:
Name Type Description Error
Object An error object that contains the properties "action", "errorCode" and "errorReason"
-
onQueryRequest
-
Event handler that is called when the capability enquiry request is received. An object contains the enquiry information to be passed to the application. This Query object contains properties like initiator, target, initiatorCapability, and targetCapability.
Parameters:
Name Type Description Query
Query An object that represents a capability enquiry
-
onQueryResponse
-
Event handler called when the capability enquiry response is received. An object contains the enquiry information to be passed to the application. This Query object contains properties like initiator, target, initiatorCapability, and targetCapability.
Parameters:
Name Type Description Query
Query An object that represents a capability query
-
onChatMessage
-
callback function for new incoming chat message.
Parameters:
Name Type Description message
ChatMessage The incoming chat message
-
onConnectionStateChange
-
callback function for the chat connection state changes.
Parameters:
Name Type Description state
ConnectionState the current chat connection state.
-
onMessage
-
For extensibility - Processes the received JSON message between the client and the WebRTC Session Controller server.
Application can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
Object the JSON message between the client and WebRTC Session Controller server
-
onMessageSendFailure
-
message send failure callback function.
Parameters:
Name Type Description msgId
String the sent message ID
status
String the status code
reason
String the reason description
-
onMessageSendSuccess
-
message send success callback function.
Parameters:
Name Type Description msgId
String the sent message ID
-
onMessageTyping
-
callback function that indicates the peer side is typing a message.
-
onMessageTypingStop
-
Callback function that indicates the other stopped typing a message.
-
onStateChange
-
callback function for Chat signalling state changes.
Parameters:
Name Type Description state
wsc.CallState An instance of CallState object
extHeaders
JSON Optional. Extension headers
-
onIncomingChat
-
Callback function for the incoming chat request.
Parameters:
Name Type Description chat
wsc.Chat an instance of wsc.Chat object
-
onMessage
-
For extensibility - Processes the received JSON message between the client and WebRTC Session Controller server.
This function handles the received messages, and dispatches messages to corresponding wsc.Chat objects. The application can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
JSON the JSON message between client and WebRTC Session Controller server
-
onMessage
-
Event handler called when a raw data object is received by the data channel of the DataTransfer object. An application should override this function to handle the received data by itself. If it is not overridden by the application, the received raw data object cannot be passed to the application to handle it.
Parameters:
Name Type Description evt
Object The event object received by the data channel. It is passed to the function complete and unmodified. The raw data can be fetched by evt.data and supports the following data types:
- Text string
- BLOB raw data
- ArrayBuffer
- ArrayBufferView
Example
var receiver = dataTransfer.getReceiver(); receiver.onMessage = function(evt) { var rcvdDataElm = document.getElementById("rcvData"); rcvdDataElm.value = evt.data; }
-
onClose
-
Event handler called when the dataChannel of a DataTransfer object is closed. An event is provided as parameter, when the handler is invoked.
Example
function onDataTransfer(dataTransfer) { console.log("Data transfer call back is called!"); // Keep the dataTransfer reference, and initialize the dataTransfer callback functions... myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCClose(evt) { // Render the web page when the data channel is closed. }
-
onError
-
Event handler called when the dataChannel of a DataTransfer object encounters an error. An event is provided as parameter, when the handler is invoked.
Example
function onDataTransfer(dataTransfer) { console.log("Data transfer call back called."); // Keep the dataTransfer reference, and initialize the dataTransfer callback functions... myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCError(evt) { // Handle the error, and render the web page as appropriate. }
-
onOpen
-
Event handler called when the dataChannel of a DataTransfer object is opened. An event is provided as parameter, when the handler is invoked.
Example
function onDataTransfer(dataTransfer) { console.log("Data transfer call back is called!"); //Keep the reference of dataTransfer, and initial the callback functions of dataTransfer. myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCOpen(evt) { //Do some render for web page when data channel is open. }
-
onConnectionStateChange
-
callback function for the file transfer connection state changes.
Parameters:
Name Type Description state
ConnectionState the current file transfer connection state.
-
onFileData
-
callback function for incoming file transfer data.
Parameters:
Name Type Description data
FileData The received file data.
-
onFileTransferFailure
-
Callback function for file transfer failure.
Parameters:
Name Type Description fileTransferId
String the file transfer ID.
status
Number the status code.
reason
String the reason description.
-
onFileTransferSuccess
-
Callback function for file transfer success.
Parameters:
Name Type Description fileTransferId
String the file transfer ID.
-
onMessage
-
For extensibility - Processes the received JSON message between the client and WebRTC Session Controller server.
An application can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
Object the JSON message between client and WebRTC Session Controller server.
-
onProgress
-
Callback function for sending file progress data.
Parameters:
Name Type Description progress
FileProgressData The progress data.
-
onStateChange
-
callback function for FileTransfer signalling state changes.
Parameters:
Name Type Description state
wsc.CallState An instance of CallState object.
extHeaders
JSON Optional. Extension headers.
-
onFileTransfer
-
Callback function for file transfer request.
Parameters:
Name Type Description fileTransfer
Object an instance of wsc.FileTransfer object.
-
onMessage
-
For extensibility - Processes the received JSON message between the client and WebRTC Session Controller server.
This function dispatches the received messages to corresponding wsc.FileTransfer objects. The application can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
Object the JSON message between the client and WebRTC Session Controller server.
-
onMessage
-
For extensibility - Processes a received message.
This function handles MessageAlertPackage messages, and lets you process Subscription object operations as required.
This is an SPI function, which can be overridden when the MessageAlertPackage object exposed by the WebRTC Session Controller JavaScript API is extended.Parameters:
Name Type Description msg
wsc.Message Received message
-
onRehydration
-
For extensibility - Handles the rehydration data.
This is an SPI function meant to be used when extending the objects exposed by the WebRTC Session Controller JavaScript API.
When a web page is reloaded, an application can use this method to rehydrate related session objects,
including the object created by MessageAlertPackage - Subscription.Parameters:
Name Type Description rehydratedData
the rehydrated data
-
onResurrect
-
Event handler. If an application would like to reload the session, this function is called when the page is reloaded to restore a Subscription. When the function is invoked, a wsc.Subscription object is provided as a parameter.
Parameters:
Name Type Description rehydratedSubscription
wsc.Subscription is an instance of a Subscription object that is rehydrated.
Example
subscribeHandler = new wsc.MessageAlertPackage(wscSession); if (subscribeHandler) { subscribeHandler.onResurrect = onResurrect; } function onResurrect(rehydratedSubscription) { // Reset related callback functions. subscription = rehydratedSubscription; subscription.onSuccess = onSubscribeSuccess; subscription.onError = onSubscribeError; subscription.onNotification = onNotification; subscription.onShutdown = onShutdown; // Initialize other part, such as page ... }
-
onErrorResponse
-
Callback function that handles message failure response.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
code
Number the error code.
reason
String the error reason.
extHeaders
JSON JSON object that represents the extension headers.
-
onNewMessage
-
Callback function for new incoming text message.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
extHeaders
JSON JSON object that represents the extension headers.
-
onSuccessResponse
-
Callback function that handles message success response.
Parameters:
Name Type Description message
MessagingMessage an JSON object that represents the message.
extHeaders
JSON JSON object that represents the extension headers.
-
failureCallback
-
the callback function for failed session creation.
-
onHibernationRequest
-
the callback function for receiving hibernate request from server side.
Parameters:
Name Type Description request
JSON Hibernate request json message.
-
onSessionStateChange
-
the callback function for session state changes.
Parameters:
Name Type Description sessionState
wsc.SESSIONSTATE the current session state.
-
successCallback
-
the callback function for a successfully created session.
Parameters:
Name Type Description extHeaders
JSON extension headers.
-
onEnd
-
Callback function to invoke when an end message for a subscription is received. The application needs to configure this callback function.
The callback function is invoked without any parameters.Example
function onEnd(){ //Render the web page when the end message for current subscription is received. var subscribeButton = document.getElementById("subscribeButton"); if(subscribeButton != null){ subscribeButton.disabled = false; } removeSubscriptionInfoElem(); }
-
onError
-
Callback function to invoke when a subscription is created with an error response. The application needs to configure this callback function.
The callback function is invoked with a subscription errorCode as its parameter.Example
function onError(errorCode) { console.log("Error code: "+errorCode); }
-
onNotification
-
Callback function to invoke when a Notify request message is received. The application needs to configure this callback function.
The callback function is invoked with a Notification wsc.Notification as a parameter.Parameters:
Name Type Description notification
wsc.Notification The wsc.Notification object which represents the received notification message.
Example
function onNotification(notification) { console.log("The sender of the notify is: "+notification.getSender()); console.log("The receiver of the notify is: "+notification.getReceiver()); }
-
onSuccess
-
Callback function to invoke when a subscription is created successfully. The application needs to configure this callback function.
The callback function is invoked with the target of the subscription as a parameter.Example
function onSubscribeSuccess(target) { showResults("The subscription for " + target + " is created successfully"); };