Indy 9
TIdHTTPDefaultSessionList
Hierarchy, Properties, Methods, Events, Unit: IdCustomHTTPServer
Implements a thread-safe container for persistent HTTP sessions.
TIdHTTPDefaultSessionList = class(TIdHTTPCustomSessionList)
Unit
IdCustomHTTPServer
Description
TIdHTTPDefaultSessionList is a TIdHTTPCustomSessionList descendant that implements the container framework declared in the ancestor class. TIdHTTPDefaultSessionList provides an implementation that uses a TThreadList to store and manage TIdHTPSession object instances.

TIdHTTPDefaultSessionList overrides abstract virtual methods from the ancestor class to implement the operations needed to maintain the session list, including:

TIdHTTPDefaultSessionList extends the ancestor by including the RemoveSessionFromLockedList method to provide thread-safe removal of a persistent session object from the internal TThreadList.

TIdHTTPDefaultSessionList is type used to represent the TIdHTTPServer.SessionList property in an HTTP server implementation.


TIdHTTPDefaultSessionList.Add
TIdHTTPDefaultSessionList
Adds a persistent HTTP session to the thread-safe container.
procedure Add(ASession: TIdHTTPSession); override;
Parameters
ASession: TIdHTTPSession
HTTP session to be added to the container.
Description
Add is an overridden procedure in TIdHTTPDefaultSessionList, and adds the persistent HTTP session specified in ASession to the thread-safe container. Add calls the TThreadList.Add method to store ASession in the thread list.

Use GetSession to retrieve a session added to the container using Add.

Use RemoveSession to delete a session from the container.


TIdHTTPDefaultSessionList.Clear
TIdHTTPDefaultSessionList
Removes HTTP sessions from the thread-safe session list.
procedure Clear; override;
Description
Clear is a procedure used to remove all TIdHTTPSession objects in the thread-safe session list. Clear will insure that the thread list is locked prior to triggering the OnSessionEnd event handler, clearing the session owner, and freeing all TIdHTTPSession instances in the list. Clear unlocks the thread list prior to exiting the method.

TIdHTTPDefaultSessionList.Create
TIdHTTPDefaultSessionList
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Component that owns the container.
Description
Create is the constructor for the object instance, and calls the inherited Create method using AOwner as the owner of the container. Create allocates resources required for the internal thread list used to store HTTP session instances, and sets the thread list capacity to the value specified in SessionCapacity.

TIdHTTPDefaultSessionList.CreateSession
TIdHTTPDefaultSessionList
Adds a new HTTP session to the thread-safe container.
function CreateSession(const RemoteIP: String; const SessionID: String): TIdHTTPSession; override;
Parameters
const RemoteIP: String
The peer IP address for the session.
const SessionID: String
The identifier for the session.
Return Value
TIdHTTPSession - The session object reference.
Description
CreateSession is a TIdHTTPSession function used to create a new persistent HTTP session, and add the new session to the container. CreateSession constructs a new TIdHTTPSession using the values specified in RemoteIP and SessionID. RemoteIP is the IP address of the remote computer system that is the endpoint for the HTTP session. SessionID is the identifier for the new HTTP session.

CreateSession is used by TIdHTTPServer to retrieve a new HTTP session when a new client connection is established.


TIdHTTPDefaultSessionList.CreateUniqueSession
TIdHTTPDefaultSessionList
Creates a new HTTP asession with a unique session ID and remote IP address.
function CreateUniqueSession(const RemoteIP: String): TIdHTTPSession; override;
Parameters
const RemoteIP: String
IP address or host name for the remote connection.
Return Value
TIdHTTPSession - new HTTP session created for a client connection.
Description
CreateUniqueSession is a TIdHTTPSession function that is ued to insure a new HTTP session is created for a client connection having the remote IP address specified in RemoteIP. CreateUniqueSession generates a random value for the session identifer used in the HTTP session, and calls to Create session when the RemoteIP and SessionID combination is guaranteed to be unique.

TIdHTTPDefaultSessionList.Destroy
TIdHTTPDefaultSessionList
Destructor for the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy is responsible for clearing and freeing resource allocated to the internal thread-safe session list for the container. Destroy calls the inherited Destroy method prior to exiting.

TIdHTTPDefaultSessionList.GetSession
TIdHTTPDefaultSessionList
Retrieves a persistent HTTP session having the specified ID and remote IP address.
function GetSession(const SessionID: string; const RemoteIP: string): TIdHTTPSession; override;
Parameters
const SessionID: string
Session identifier to be located.
const RemoteIP: string
Optional remote IP address for the session.
Return Value
TIdHTTPSession - Persisten session retrieved from the container.
Description
GetSession is a TIdHTTPSession function used to retrive a persistent HTTP session having the remote IP address and session identifier specified in SessionID and RemoteIP. GetSession insures that the internal thread list is locked prior to accessing sessions in the container.

GetSession will iteratively search through all sessions in the container until a session is located with the specified SessionID and RemoteIP. If RemoteIP contains an empty string, the first session with the same session identifier is used.

When a session is located for the session identifer and remote IP address, the session is timestamped for last access to prevent purging as a stale session.

The return value for GetSession can contain Nil when a session cannot be located with the specified values.

GetSession will unlock the internal thread list prior to exiting from the method.


TIdHTTPDefaultSessionList.PurgeStaleSessions
TIdHTTPDefaultSessionList
Removes one or more expired sessions from the session list.
procedure PurgeStaleSessions(PurgeAll: Boolean = false); override;
Parameters
PurgeAll: Boolean = false
Clear one or all stale sessions. Default value is False.
Description
PurgeStaleSessions is a procedure used to remove persistent HTTP sessions where the last access timestamp and session timeout properties indicate that the session has expired. PurgeStaleSessions can be used to remove one or more session that have expired, as indicated in the PurgeAll argument.

PurgeStaleSessions will iteratively call RemoveSessionFromLockedList to remove the expired session(s). PurgeStaleSessions insures that the internal thread list is locked prior to removing stale sessions, and is unlocked prior to exiting from the method.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.