Jump to content

How to manually stop a session?


njtz2011

Recommended Posts

I want to manually stop a session,but I can't find ways to achieve,The following code no effect.

 

 

  ASession := TUniGUISession(UniServerModule.SessionManager.Sessions.GetSession(SomeSessionID,SomeRemoteHost));
 if ASession <> nil then
    ASession.UniApplication.Terminate;
    //or
    UniServerModule.ClearSessionBusy(ASession);

Link to comment
Share on other sites

Hi,

 

try

 

 UniApplication.Restart; 

 

or

 

  UniApplication.Terminate; 

 

both routines will destory tmainmodule, wiche is representing a session. UniApplication is always valid and bound to sessions' context.

Link to comment
Share on other sites

I want to manually stop a session,but I can't find ways to achieve,The following code no effect.

 

 

  ASession := TUniGUISession(UniServerModule.SessionManager.Sessions.GetSession(SomeSessionID,SomeRemoteHost));
 if ASession <> nil then
    ASession.UniApplication.Terminate;
    //or
    UniServerModule.ClearSessionBusy(ASession);

 

You can do the following:

 

UniSession.Logout

 

Remember that UniSession it's a function of "uniGUIApplication" unit that retrieves the current session.

 

But if you are managing the sessions in "global" scope, first you have to get the TUniGUISession.

So, you can do the following:

 

uses ServerModule;

procedure KillSession;
var Sessions: TList;
   Session: TUniGUISession;
   I: Integer;
begin
   Sessions := UniServerModule.SessionManager.Sessions.SessionList.LockList;
   try
     for I := 0 to Sessions.Count - 1 do
     begin
         Session := Sessions[i];

         Secao.Lock;
         try
           if Session.(SessionID/IP/Address) = (????) then
             Session.Logout;
         finally
           Secao.Unlock;
         end;
     end;
   finally
     UniServerModule.SessionManager.Sessions.SessionList.UnlockList;
   end;
end;

Link to comment
Share on other sites

  • 4 months later...

Terminating a session terminates MainModule.

Meybe Connections are cached internally.

 

 

At first not.... I've tried closing sessions with diferent methos:

 

session.uniapplication.terminate

session.logout

session.unimainmodule.terminate

 

 

which should be the right one?

 

THX

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...