Jump to content

ServerModule Test For Active Sessions - How ?


andyhill

Recommended Posts

My code below walks through ALL MainModules fetching their MyUserName's - All Good.

Problem, when sessions are no longer active (closed down [browser gone]) they still show up as active connected sessions.

How can I determine if a session in the list has died ???

function TUniServerModule.GetSessionLoggedInUserNames(): String;
var
  I: Integer;
  S: TUniGUISessions;
  U: TUniGUISession;
begin
  Result:= '';
  S:= UniServerModule.SessionManager.Sessions;
  S.Lock;
  try
    SetLength(ASessionList, S.SessionList.Count);
    for I:= 0 to S.SessionList.Count - 1 do begin
      U:= S.SessionList;
      ASessionList.ASessionId:= U.SessionId;
      ASessionList.AIP:= U.RemoteIP;
      ASessionList.ALastTime:= U.LastTimeStamp;
      if U.UniMainModule <> nil then begin
        if U.Active = True then begin // Need Dead Session Logic Here
          if I = 0 then begin
            Result:= (U.UniMainModule as TUniMainModule).MyUserName;
          end else begin
            Result:= Result + ', ' + (U.UniMainModule as TUniMainModule).MyUserName;
          end;
        end;
      end;
    end;
  finally
    S.Unlock;
  end;
end;

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