TAstaServerSocket.CreateSessionsForDbThreads


 

Applies to
TAstaServerSocket

 

Declaration
procedure CreateSessionsForDBThreads(FreeSessions: Boolean);

 

This is called in an ASTA server when the server first starts and initializes the AstaSessionList when running an ASTA server. If you want ASTA to free the sessions set it to True. The SessionList can be reinitialized at runtime by freeing and re-calling CreateSessionsforDBThreads. This would be necessary if the Database is being backed up and no database connections where allowed.

 

 

The following is an example from the AstaDOAServer (Direct Oracle Access) that frees the SessionList and creates it again.

 

Procedure TFrmMain.ReLogonToAllSessions;

var

i:Integer;

ADM:TastaOracleDataModule;

begin

try

 if DM.MainLogon.Session.Connected then DM.MainLogon.Session.LogOff;

 DM.MainLogon.Session.LogOn;

  mrequests.lines.add('Main Database reconnected');

 except

  mrequests.lines.add('Problems reconnecting to Main Login'+' '+EDataBaseError(ExceptObject).Message);

end;

try

//with a single session there is no SessionList

 if AstaServerSocket1.ThreadingModel=tmSingleSession then exit;

  for i:=0 to AstaServerSocket1.SessionList.Count-1 do begin

   //walk the session list and type cast and call whatever routines are needed

   //to check to see if it is connected and then re-logon

    Adm:=AstaServerSocket1.SessionList.GetSession(i) as TAstaOracleDataModule;

    if Adm.MainLogon.Session.Connected then Adm.MainLogOn.Session.LogOff;

    Adm.MainLogOn.Session.LogOn;

    mrequests.lines.add('Session '+InttoStr(i)+' reconnected');

   end;

 except

    mrequests.lines.add('Session List Reconnect Problem. '+EDataBaseError(ExceptObject).Message);

    //try again!!!

    AstaServerSocket1.SessionList.Free;

    AstaServerSocket1.SessionList:=nil;

    AstaServerSocket1.CreateSessionsForDbThreads(True);

    //this calls the OnDBSupplySession event of the AstaServerSocket

end;

end;

 

 

 

See Threading ASTA Servers for a fuller discussion.



ASTA Overview TAstaServerSocket.ClientLogin TAstaServerSocket.DataBaseSessions