vbdavie Posted March 31, 2019 Share Posted March 31, 2019 I've spent some time looking for a way to get a list of sessions from the servermodule or mainmodule and can't seem to find anything. I want to be able to see a list of users that are using the app. So, if 10 people are on-line, then I should be able to see all 10 of their session instances. Some kind of instance array. Once I have this, I am hoping that I can issue some sort of "LogOut" method to KILL a specific user. Is this possible? Thanks Davie Quote Link to comment Share on other sites More sharing options...
adragan Posted April 2, 2019 Share Posted April 2, 2019 To save the time, I got it from an example var S : TUniGUISessions; U : TUniGUISession; i , nr: Integer; ASessionList : array of TUniSessionInfoRec; begin S := UniServerModule.SessionManager.Sessions; nr:=S.SessionList.Count; S.Lock; // Using Lock on session manager should be used with extreme care. // We should keep this "Lock" active as short as we can. Session Manager stops working until lock is released. // Excessive use of lock/unlock or keeping the lock active for a long period will make uniGUI server slow/unresponsive. try SetLength(ASessionList, S.SessionList.Count); // Here we do a fast copy of list to another array for later use. nr:= S.SessionList.Count - 1; for i := 0 to nr do begin U := S.SessionList; ASessionList.ASessionId := U.SessionId; ASessionList.AIP := U.RemoteIP; ASessionList.ALastTime := U.LastTimeStamp; end; finally S.Unlock; // ... and finally don't forget to release lock! end; 1 Quote Link to comment Share on other sites More sharing options...
SMARAM Posted October 30, 2023 Share Posted October 30, 2023 The same code in C++ Builder, if someone needs it. TStringList *lstSessions = new TStringList(); TUniGUISessions *S = UniServerModule()->SessionManager->Sessions; int nr = S->SessionList->Count; S->Lock(); // Using Lock on session manager should be used with extreme care. // We should keep this "Lock" active as short as we can. Session Manager stops working until lock is released. // Excessive use of lock/unlock or keeping the lock active for a long period will make uniGUI server slow/unresponsive. try { // Here we do a fast copy of list to another array for later use. for (int i=0; i<nr; i++) { TUniGUISession *U = (TUniGUISession*)S->SessionList->Items[i]; lst->Add("SessionId: " + U->SessionId); lst->Add("RemoteIP: " + U->RemoteIP); lst->Add("LastTimeStamp: " + U->LastTimeStamp); } } __finally { S->Unlock(); // ... and finally don't forget to release lock! } Quote Link to comment Share on other sites More sharing options...
55143681 Posted November 13, 2023 Share Posted November 13, 2023 On 10/31/2023 at 3:05 AM, SMARAM said: The same code in C++ Builder, if someone needs it. TStringList *lstSessions = new TStringList(); TUniGUISessions *S = UniServerModule()->SessionManager->Sessions; int nr = S->SessionList->Count; S->Lock(); // Using Lock on session manager should be used with extreme care. // We should keep this "Lock" active as short as we can. Session Manager stops working until lock is released. // Excessive use of lock/unlock or keeping the lock active for a long period will make uniGUI server slow/unresponsive. try { // Here we do a fast copy of list to another array for later use. for (int i=0; i<nr; i++) { TUniGUISession *U = (TUniGUISession*)S->SessionList->Items[i]; lst->Add("SessionId: " + U->SessionId); lst->Add("RemoteIP: " + U->RemoteIP); lst->Add("LastTimeStamp: " + U->LastTimeStamp); } } __finally { S->Unlock(); // ... and finally don't forget to release lock! } How to kill a session? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.