Class: Session

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 process 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 the same sub-session ID.

new Session(userName, webSocketUri, successCallback, failureCallback, sessionId, extHeaders, extPayloads, stateInfo)

Parameters:
Name Type Description
userName String

the user name

webSocketUri String

the WebSocket server URI

successCallback

the success callback function

failureCallback

the failure callback function

sessionId String

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.

extHeaders JSON

extension headers.

extPayloads JSON

extension payload for push notification service.

stateInfo JSON

Session data for rehydration.

Members

ackInterval

the interval that client periodly sending acknowledgement message. The default value is 60000ms.

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.

timeToLive

the Server will cleanup the session if client does not rehydrate this given timeToLive.

webSocketUri

the websocket uri.

Methods

close()

Closes the session and releases all the underlying resources.

Fires:
  • wsc.Session.event:onSessionStateChange

getSessionId()

Gets the session ID.

getUserName()

Gets the user name

hibernate(timeToLiveInSecs, onSuccess, onError)

Sends the hibernate request to the WebRTC Session Controller server.

Parameters:
Name Type Description
timeToLiveInSecs Number

the expected living time of a hibernated session, if expired, the hibernated session will not be rehydrated.

onSuccess

the hibernate success callback function

onError

the hibernate failure callback function

setBusyPingInterval(pingInterval)

Sets the value of wsc.Session#busyPingInterval, the minimal value is 1000ms.

Parameters:
Name Type Description
pingInterval String

the interval value in milliseconds

setIdlePingInterval(pingInterval)

Sets the value of wsc.Session#idlePingInterval, the minimal value is 1000ms.

Parameters:
Name Type Description
pingInterval String

the interval value in milliseconds

setReconnectInterval(reconnectInterval)

Sets the value of wsc.Session#reConnectInterval

Parameters:
Name Type Description
reconnectInterval String

the interval value in milliseconds

setReConnectTime(time)

Sets the value of wsc.Session#reConnectTime.

Parameters:
Name Type Description
time String

the value in milliseconds

suspend() → {String}

Suspends the session. Invoking this method will trigger WebSocket abnormal close and also return session data used by rehydration.

Fires:
  • wsc.Session.event:onSessionStateChange
Returns:

JSON format session data.

Type
String

Events

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.

Oracle® Communications WebRTC Session Controller Javascript API Reference 7.2.0.1.1, E69512-02
Copyright © 2013, 2017, Oracle and/or its affiliates. All rights reserved.