Index


Class wsc.Session

Represents a session between the client and the WebRTC Session Controller server. A client application is expected to create only one session towards the WebRTC Session Controller server for each user. A session may have one or more sub-sessions.

A wsc.AuthHandler object should be created to get "SERVICE", "TURN" or other authentication information. When a wsc.AuthHandler is created using "new wsc.AuthHandler(session)", it registers with the session implicitly.
When receiving an incoming message from WebRTC Session Controller, the session dispatches the message to the appropriate package handler like, wsc.CallPackage or wsc.MessagelertPackage in order to the message.

The package handlers can create a sub-session to process the message if needed. For example, the wsc.CallPackage creates a wsc.Call to process call related messages. This wsc.Call is a sub-session. All the messages that belong to a call share a same sub-session ID.

Class Summary
Constructor Attributes Constructor Name and Description
 
wsc.Session(userName, webSocketUri, successCallback, failureCallback, sessionId, extHeaders)
Field Summary
Field Attributes Field Name and Description
 
the ping interval at busy time.
 
the ping interval at idle time.
 
the reConnect interval when a webSocket is abnormally closed.
 
the reConnect time when a webSocket is abnormally closed.
 
the timeout retry count.
 
the session id.
 
the websocket uri.
Method Summary
Method Attributes Method Name and Description
 
Closes the session and release all the underlying resources.
 
Gets the session id.
 
Gets user name
 
setBusyPingInterval(pingInterval)
Sets the value of wsc.Session#busyPingInterval, the minimal value is 1000ms.
 
setIdlePingInterval(pingInterval)
Sets the value of wsc.Session#idlePingInterval, the minimal value is 1000ms.
 
setReconnectInterval(reconnectInterval)
 
Sets the value of wsc.Session#reConnectTime
Event Summary
Event Attributes Event Name and Description
 
the callback function for failed session creation.
 
onSessionStateChange(sessionState, sessionState)
The callback function for session state changes.
 
successCallback(sessionState)
The callback function for a sucessfully created session.
Class Detail
wsc.Session(userName, webSocketUri, successCallback, failureCallback, sessionId, extHeaders)
Parameters:
{String} userName
the user name
{String} webSocketUri
the WebSocket server URI
successCallback
the success callback function
failureCallback
the failure callback function
{String} sessionId
If an application provides the sessionId, the client will try to rehydrate the Session with the given id; otherwise, the client will create a new Session.
{Object} extHeaders
extension headers. If provided, they will be inserted into JSON message.
For example, an extHeaders in this format, {'customerKey1':'value1','customerKey2':'value2'}
is tranformed into the following JSON:
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}
Field Detail
busyPingInterval
the ping interval at busy time. The default value is 3000ms. This ping interval is used when there are subSessions inside the Session.

idlePingInterval
the ping interval at idle time. The default value is 10000ms. This ping interval is used when there are no subSessions inside the Session. This value should not be greater than the WebRTC Session Controller server side value of "WebSocket Idle Time Limit".

reConnectInterval
the reConnect interval when a webSocket is abnormally closed. The default value is 2000ms.

reConnectTime
the reConnect time when a webSocket is abnormally closed. The default value is 60000ms. This value should not be greater than the WebRTC Session Controller server side value of "WebSocket Disconnect Time Limit".

retryCount
the timeout retry count. If this value is reached, the client will start the reconnect process. The default value is 2.

sessionId
the session id.

webSocketUri
the websocket uri.
Method Detail
close()
Closes the session and release all the underlying resources.

getSessionId()
Gets the session id.

getUserName()
Gets user name

setBusyPingInterval(pingInterval)
Sets the value of wsc.Session#busyPingInterval, the minimal value is 1000ms.
Parameters:
{String} pingInterval
the interval value in milliseconds

setIdlePingInterval(pingInterval)
Sets the value of wsc.Session#idlePingInterval, the minimal value is 1000ms.
Parameters:
{String} pingInterval
the interval value in milliseconds

setReconnectInterval(reconnectInterval)
Sets the value of wsc.Session#reConnectInterval
Parameters:
{String} reconnectInterval
the interval value in milliseconds

setReConnectTime(time)
Sets the value of wsc.Session#reConnectTime
Parameters:
{String} time
the value in milliseconds
Event Detail
failureCallback()
the callback function for failed session creation.

onSessionStateChange(sessionState, sessionState)
The callback function for session state changes. If the session state change from RECONNECTING to CONNECTED, the application need compare the current session id with the previous session id. If they are the same, it means the session rehydration succeeded; otherwise, the rehydration failed and a new session is created. the callback function for session state changes.
Parameters:
{wsc.SESSIONSTATE} sessionState
the current session state.
{boolean} sessionState
the current session state.

successCallback(sessionState)
The callback function for a sucessfully created session. If the application create the session with a session id, when this callback is invoked, the application must compare that session id with the previous session id. If they are the same, session rehydration has succeeded; otherwise, rehydration failed and a new session is created. the callback function for a sucessfully created session.
Parameters:
{boolean} sessionState
the current session state

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