Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New version 15.1.0 is now available
#8
(07-15-2019, 09:00 AM)matija Wrote: My function in ServerController:

Try this code instead. Session list doesn't use any locking mechanism. Have in mind that GSessions.Terminate() might fail to terminate the desired session if it is currently locked by the user. It is not possible to remove a session being used by another thread.
 
Code:
procedure TIWServerController.KillDoubleSession(const Username: string);
var
  LSessions: TStringList;
  i:Integer;
  cAppID: string;
  LFound: Boolean;
begin
  cAppID:='';

  LSessions := TStringList.Create;
  try
    gSessions.GetList(LSessions);

    LFound := False;
    for i := 0 to Pred(LSessions.Count) do
    begin
      gSessions.Execute(LSessions[i],
        procedure(aSession: TObject)
        var
          LSession: TIWApplication absolute aSession;
        begin
          LFound := (LSession.Data as TIWUserSession).WebUser.Username = Username;
          if LFound then
            cAppID := LSessions[i];
        end
      );
      if LFound then
        Break;
    end;
  finally
    LSessions.Free;
  end;

  if cAppID <>'' then
  begin
    GSessions.Terminate(cAppID);
  end;
end;
Reply


Messages In This Thread
RE: New version 15.1.0 is now available - by Alexandre Machado - 07-15-2019, 09:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)