Event Sink

HI,

I create event sink server which monitor the active connection.

When I shutdown the server and there is a connected client , the server show a error ROEventRepository.Message must be assigned. I checked it is really assigned.

How to solve this issue?

Hi,

Pls specify what exactly TROEventRepository descendant you are using

TROInMemoryEventRepository, Latest SDK and delphi 10.3.3 , win10

I Follow the SuperTCPChannelChat and put the following shutdown event code in servdermodule ondestroy event:

procedure TServerDataModule.DataModuleDestroy(Sender: TObject);
var
ev: IChatEvents_Writer;
begin
ev := (ROEventRepository as IChatEvents_Writer);
ev.Shutdown(EmptyGUID);
Sleep(2000); // allow clients to gracefully logout.
end;

The other eventsink method is correct. Just this Shutdown event client did not receive.

Please advise.

Hi,
In SuperTCPChannelChat we used FormCloseQuery event - this event is fired when components in Datamodule weren’t destroyed yet.

i.e. it sends notifications, and after this close main form.
In your case, some components could be destroyed, like message component, and it is a reason why ROEventRepository.Message is nil.

Then is it a issue or not? How to handle is better , as I need run in a service mode.

Also why the shutdown function not sink to client ? How to check ? as all other function is working only this shutdown not working.

you should extract that code into personal method and call it before your data module is freed, like

   datamodule.Shutdown;
   datamodule.Free;

If i need achieve is when the server in service mode, before shutdown/Destroy, in which module/event I can notice client to disconnect from server ?

For example, execute “datamodule.shutdown”
Any advice?

Hi,

for Windows Service template, you can use OnStop event, like

procedure TService1.ServiceStop(Sender:TService; var Stopped:Boolean);
begin
  // add here your code
  RoServer.Active := false;
end;