Jump to content

Recommended Posts

Posted

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);

Posted

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.

Posted

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;

  • 4 months later...
Posted

Hello, I've tried to terminate/close sessions manually, and the user is dropped, but the connection to mysql is still active. It's like if the unimainmodule still alive.

 

I use MyDac to connect to Mysql.

 

THX

Posted

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

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...