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.
Constructor Attributes | Constructor Name and Description |
---|---|
wsc.Session(userName, webSocketUri, successCallback, failureCallback, sessionId, extHeaders)
|
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 Attributes | Method Name and Description |
---|---|
close()
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#reConnectInterval
|
|
setReConnectTime(time)
Sets the value of wsc.Session#reConnectTime
|
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.
|
- 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" : {}}
- Parameters:
- {String} pingInterval
- the interval value in milliseconds
- Parameters:
- {String} pingInterval
- the interval value in milliseconds
- Parameters:
- {String} reconnectInterval
- the interval value in milliseconds
- Parameters:
- {String} time
- the value in milliseconds
- Parameters:
- {wsc.SESSIONSTATE} sessionState
- the current session state.
- {boolean} sessionState
- the current session state.
- Parameters:
- {boolean} sessionState
- the current session state