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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...