Library for managing client-side OT session.
ClientSession object manages the overall interaction with the OT server. It maintains information on which user is
authenticated (in the
user property) as well as the state of the overall server interaction (connected, authorized).
A user registers callback listeners for certain events: 'status', 'join', 'state'. The callbacks are passed the
object and the ClientSessionState associated with the event.
Each separate OT session is represented by a
ClientSessionState object. These have a
clientID that uniquely
identifies them. The
state property contains the current OT state. The
clientEngine property is used for posting new
In order to drive session activity, a client should call the
tick method at regular intervals. For convenience,
speed property on the
ClientSession object contains a
SpeedManager object that provides an appropriate
timeout interval for ticking the session state machine. This is a short interval when there is much activity and backs
off as the system quiets in order to reduce overall CPU load as well as server pinging (although the server implements
long-polling to prevent excessive traffic when there is little activity).
This library currently supports a single current session for tracking what to display in a single-page app. With minor
changes, this could be changed to allow multiple current sessions. Right now the
ClientSession object will only advance
the state machine of the single current session, although any outstanding requests and their responses on non-current sessions
will be processed correctly.