Session constructor
Constructor
Creates a new session and associate it to the server
.
The timeout
is the duration the session remains alive, before it
is automatically terminated. The timeout timer is restarted when a new
HTTP request is received that is associated with the session.
The timeout
duration cannot be null.
The expiry duration can be changed using the timeout
method.
Implementation
Session(Server server, Duration timeout)
: _server = server,
_created = DateTime.now(),
_timeout = timeout {
// Set up expiry timer to expire this session if it
// becomes inactive (i.e. is not used after some time).
_refresh(); // create a new expiry timer
// Register it in the Web server's list of all sessions
assert(!_server._allSessions.containsKey(id));
server._sessionRegister(this);
_logSession.fine('[session:$id]: created');
}