lib/server/server_session.js
/**
 *
 * A Server session object.
 *
 * **from OPCUA Spec 1.02:**
 *
 * * Sessions are created to be independent of the underlying communications connection. Therefore, if a communication
 *   connection fails, the Session is not immediately affected. The exact mechanism to recover from an underlying
 *   communication connection error depends on the SecureChannel mapping as described in Part 6.
 *
 * * Sessions are terminated by the Server automatically if the Client fails to issue a Service request on the Session
 *   within the timeout period negotiated by the Server in the CreateSession Service response. This protects the Server
 *   against Client failures and against situations where a failed underlying connection cannot be re-established.
 *
 * * Clients shall be prepared to submit requests in a timely manner to prevent the Session from closing automatically.
 *
 * * Clients may explicitly terminate Sessions using the CloseSession Service.
 *
 * * When a Session is terminated, all outstanding requests on the Session are aborted and Bad_SessionClosed StatusCodes
 *   are returned to the Client. In addition, the Server deletes the entry for the Client from its
 *   SessionDiagnosticsArray Variable and notifies any other Clients who were subscribed to this entry.
 *
 * @class ServerSession
 *
 * @param parent {SessionEngine}
 * @param sessionId {Number}
 * @param sessionTimeout {Number}
 * @private
 * @constructor
 */
A Server session object.



Sessions are created to be independent of the underlying communications connection. Therefore, if a communication
connection fails, the Session is not immediately affected. The exact mechanism to recover from an underlying
communication connection error depends on the SecureChannel mapping as described in Part 6.

Sessions are terminated by the Server automatically if the Client fails to issue a Service request on the Session
within the timeout period negotiated by the Server in the CreateSession Service response. This protects the Server
against Client failures and against situations where a failed underlying connection cannot be re-established.

Clients shall be prepared to submit requests in a timely manner to prevent the Session from closing automatically.

Clients may explicitly terminate Sessions using the CloseSession Service.

When a Session is terminated, all outstanding requests on the Session are aborted and Bad_SessionClosed StatusCodes
are returned to the Client. In addition, the Server deletes the entry for the Client from its
SessionDiagnosticsArray Variable and notifies any other Clients who were subscribed to this entry.




A Server session object . Sessions are created to be independent of the underlying communications connection . Therefore if a communication connection fails the Session is not immediately affected . The exact mechanism to recover from an underlying communication connection error depends on the SecureChannel mapping as described in Part 6 . Sessions are terminated by the Server automatically if the Client fails to issue a Service request on the Session within the timeout period negotiated by the Server in the CreateSession Service response . This protects the Server against Client failures and against situations where a failed underlying connection cannot be re - established . Clients shall be prepared to submit requests in a timely manner to prevent the Session from closing automatically . Clients may explicitly terminate Sessions using the CloseSession Service . When a Session is terminated all outstanding requests on the Session are aborted and Bad_SessionClosed StatusCodes are returned to the Client . In addition the Server deletes the entry for the Client from its SessionDiagnosticsArray Variable and notifies any other Clients who were subscribed to this entry .
function ServerSession(parent, sessionId, sessionTimeout) {
    var self = this;
    self.parent = parent; 
    EventEmitter.apply(self, arguments);
    assert(_.isFinite(sessionId));
    assert(sessionId !== 0, " sessionId is null/empty. this is not allowed");
    assert(_.isFinite(sessionTimeout));
    assert(sessionTimeout >= 0, " sessionTimeout");
    self.sessionTimeout = sessionTimeout;
    var authenticationTokenBuf = crypto.randomBytes(16);
    self.authenticationToken = new NodeId(NodeIdType.BYTESTRING, authenticationTokenBuf);
    self.nodeId = new NodeId(NodeIdType.GUID, ec.randomGuid(), 1);
    assert(self.authenticationToken instanceof NodeId);
    assert(self.nodeId instanceof NodeId);
    self._cumulatedSubscriptionCount = 0;
    self.publishEngine = new ServerSidePublishEngine({
        maxPublishRequestInQueue: ServerSession.maxPublishRequestInQueue
    });
    self.publishEngine.setMaxListeners(100);
    theWatchDog.addSubscriber(self, self.sessionTimeout);
    self.__status = "new";
    self.continuationPointManager = new ContinuationPointManager();
    self.creationDate = new Date();
}
function ServerSession ( parent , sessionId , sessionTimeout ) { var self = this ; self . parent = parent ; EventEmitter . apply ( self , arguments ) ; assert ( _ . isFinite ( sessionId ) ) ; assert ( sessionId !== 0 , " sessionId is null/empty. this is not allowed" ) ; assert ( _ . isFinite ( sessionTimeout ) ) ; assert ( sessionTimeout >= 0 , " sessionTimeout" ) ; self . sessionTimeout = sessionTimeout ; var authenticationTokenBuf = crypto . randomBytes ( 16 ) ; self . authenticationToken = new NodeId ( NodeIdType . BYTESTRING , authenticationTokenBuf ) ; self . nodeId = new NodeId ( NodeIdType . GUID , ec . randomGuid ( ) , 1 ) ; assert ( self . authenticationToken instanceof NodeId ) ; assert ( self . nodeId instanceof NodeId ) ; self . _cumulatedSubscriptionCount = 0 ; self . publishEngine = new ServerSidePublishEngine ( { maxPublishRequestInQueue : ServerSession . maxPublishRequestInQueue } ) ; self . publishEngine . setMaxListeners ( 100 ) ; theWatchDog . addSubscriber ( self , self . sessionTimeout ) ; self . __status = "new" ; self . continuationPointManager = new ContinuationPointManager ( ) ; self . creationDate = new Date ( ) ; }
A Server session object.
A Server session object .
// SessionEngine
 // the sessionId
 /**
     * the continuation point manager for this session
     * @property continuationPointManager
     * @type {ContinuationPointManager}
     */ /**
     * @property creationDate
     * @type {Date}
     */