Jump to content

Recommended Posts

Posted
Hello friends,
I'm trying to notify the session on its closure.
But the message is not displayed
This function is for this reason, or is there some other way to communicate the session that it will be closed.
 
 
 unisession.ShowAlert('A sessão será finalizada dentro de cinco minutos para atualização do sistema');
 unisession.TerminateAfterSecs(60);
 
 
          try
             AServerUpdating := true;
             S := UniServerModule.SessionManager.Sessions;
             S.Lock;
             for I := 0 to S.SessionList.Count - 1  do
             begin
                  USession := S.SessionList;
                  USession.ShowAlert('Sua sessão será finalizada em 5 (cinco) minutos para atualização do sistema.');
                  USession.TerminateAfterSecs(60);
             end;
          finally
              S.Unlock;
          end;

 

Posted

This can't work with HTTP. HTTP is always: Request (from Client) -> Answer (from server). In Your Example, there are no Requests (from the different sessions), so the server can't give an answer.

 

You need long polling or web sockets...

Posted

Hi,

 

I think for your issue, you can use uniTimer with an interval a few minutes..

 

1. UniServerModule:  

  public
    { Public declarations }
    globalTerminate: Boolean;
  end;

2.

procedure TMainForm.UniTimer1Timer(Sender: TObject);
begin
  // UniTimer->Interval = 60000
  if UniServerModule.globalTerminate then
  begin
    (Sender as TUniTimer).Enabled := False;
    ShowMessage('Sua sessão será finalizada em 5 (cinco) minutos para atualização do sistema.');
  end;
end;

3.

try
  UniServerModule.globalTerminate := true; //<---
  AServerUpdating := true;
  S := UniServerModule.SessionManager.Sessions;
  S.Lock;
  for I := 0 to S.SessionList.Count - 1  do
  begin
    USession := S.SessionList[I];
    //USession.ShowAlert('Sua sessão será finalizada em 5 (cinco) minutos para atualização do sistema.');
    USession.TerminateAfterSecs(120);
  end;
finally
  S.Unlock;
end;

Best regards.

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