How to send log events to client (delphi) example

Hi,

we have ClearSessions(False); in destructor:

destructor TROInMemorySessionManager.Destroy;
begin
..
  ClearSessions(False);

try to change order of TROHttpServer and TROInMemorySessionManager on form/datamodule.

you can send events. try to use the OnCloseQuery event as we do in the SuperTCP Chat sample (Delphi) .

Hi
I’ve changed the order of freeing components and, indeed, when I free InMemorySessionManager first (before ThttpServer) it worked and I don’t need to clearSessions manually.
It worked too to change events and use formCloseQuery when I start the server manually in order to let clients know that the server is down and close gracefully.

The only problem is when starting server as a Windows Service.
I use this code in project file to do that:

sServiceName := ExtractFileName(Application.ExeName);
  sServiceName := StringReplace(sServiceName, ExtractFileExt(sServiceName), '', [rfReplaceAll]);
  if ROStartService(sServiceName, sServiceName, 'Server Name') then begin
    ROService.CreateForm(TdtmService,dtmService);
    ROService.Run;
    exit;
  end;

Is there a safe event there where I can hook the code to send something to client in order to let him know that the server is down?

Hi,

try to use TdtmService.BeforeDestruction; method. it is called before RO components are destroyed.

Perfect, it worked!

Thanks