This document is for technical topics regarding the
NetTalk infrastructure, and the ways it can be overridden.
The session data store was changed in NetTalk 12 so
that it was accessible via an interface, rather than as a part of the
NetWeb Server class. the shipping interface, and supporting class, is
based on a queue. Making it an interface means that developers can write
classes for alternate stores. While this is not common, it is useful in
some cases.
By specifying it as an interface there is an implicit promise that the
interface itself will remain stable (and indeed the interface itself was
unchanged during the NetTalk 12 cycle.) Equally, the server object only
accesses the session information via the interface, not directly.
The interface version is numbered to match the NetTalk version where it
debuted.
The interface is defined in
NetWebSessionsInterface.Inc.
The shipping implementation is in
netwebsessions.inc
and
netwebsessions.clw.
Version 14
With NetTalk 14 some changes to the interface were
proposed and implemented. Barring immediate feedback, the interface
should remain fixed for at last the NetTalk 14 cycle.
If you made an alternate interface for NetTalk 12, then there will be
some changes to use NetTalk 14. These should hopefully be minor, and
do'able in a short period of time.
Method |
Status |
Description |
_UpdateSessionValue |
New |
Updates a session value, if it exists. If it does not exist
then the value is not added to the Session Data.
This method has 3 forms, following the same parameters as
_SetSessionValue.
Returns true if a value was written, false otherwise. |
_UpdateSessionValues |
New |
Update multiple session values for all sessions, or all tabs
in a session. |
_GetSessions
|
New
|
Returns a list of sessions that match the passed filter. This
allows for getting all the expired sessions (which can then be
used to bulk-delete sessions) and so on. Returned as a
list, in a stringtheory object, already split into lines.
|
_GetSessionCustom
_SetSessionCustom |
New |
An extra field has been added in the
NetWebServerSessionQueueType called Custom. This is a
StringTheory object. Useful to developers for storing "extra"
information at the session level. Not used by NetTalk code.
If upgrading a V12 interface, then note change to DESTRUCT to
kill SessionQueue correctly. |
_SessionExpired (recordnumber)
|
deprecated
|
This method presumes that the session store has record
numbers. Which it might not. Use GetSessions instead.
|
_SessionExpired(SessionId)
_SessionExpired() |
New |
Use these to determine if a session has expired. |
Notes
- The use of the self.server property
must ONLY occur OUTSIDE Wait/Release pairs, to ensure that deadlocks
are not possible. If your derived class cannot do this then derive
the Wait and Release methods to use the self.Server._wait and
self.Server._release instead.
- SaveState updated to using jFiles instead of xFiles because jFiles
is always available whereas xFiles is optional. Since they can (now)
reflect an object, the external names for the properties are set,
and the code is greatly simplified.
One obvious optimization when using an alternate
session store is to make the store responsible for deciding that a s
ession is old and can be removed. This removes the work
from the WebServer, and therefore improves WebServer performance. This
technique is known as out-of-band deleting.
However this approach should be used with caution. Doing out of band
deletes effectively bypasses two (optional) NetTalk Features;
- When a session is deleted the WebHandler.NotifyDeleteSession
method is called. This allows the server program to clean any custom
resources (like Memory tables) that may be associated with the
session. Doing out-of-band deletes would obviously bypass this call.
- If a client has a web socket connection open, then the server does
not end the session. In other words WebSocket connections are
considered to be "forever" sessions. This test is done by the server
(by consulting the self.server.WebSocketServer
object). Obviously out-of-band deletes bypass this check.