CodeFirst EventSink missing in InterfaceFile

Hi there,
First time i try with a code first server using eventsinks. Look at this simple declaration server side:

snippet.pas (1.2 KB)

When i generate client interfacefile - there are only the [ROServiceMethod] available. No EventSink Interface at all. By accident i’ve tried to call the eventsink in a service method like:

other_snippet.pas (282 Bytes)

Now compile server and update interface from client - Interface and Eventsink is available in client interfacefile now.

How to do it a proper way? Is ist possible to register the eventsink somehow?

I’m using Delphi 10.4 with RO

Edit: how could one quote delphi code inside a topic?


this is a Delphi “feature” - all unused code is removed at compiler/linkeR stage so it is impossible to retrieve it in run-time.

you can create a empty method that accepts IROEventSink and call it from initialization like

procedure RegisterEventSink(aEvent: IROEventSink);


put delphi code inside ``` like


Thanks Evgeny!

Sorry, i was to fast
with your above suggestion compiler says: incomatible types: ‘IROEventSink’ and ‘TGUID’.
Whats wrong?


looks like delphi compiler treats interface declaration as TGUID so you can’t pass name of interface to method that accepts [reference to] interface.

workaround: try to use event sink somewhere in code

But this workaround works only if i use event sink directly in a [ROServiceMethod] in implementation.pas. If i use it in the datamodule where the businesslogic is - the event sink will not be created in interface file.
The only way i see at the moment is to work with a condition - just to generate event sink in interface…


this is incorrect.
you can test this behavior in the HTTP Chat (CodeFirst) sample:

  • copy IHTTPChatServerEvents interface under new name (like IHTTPChatServerEvents_replica) and change it’s guid
  • replace IHTTPChatServerEvents with new name in HTTPChatServerMain.pas once, so IHTTPChatServerEvents and IHTTPChatServerEvents_replica will be used.
  • launch server
  • open http://localhost:8099/bin and check that IHTTPChatServerEvents_replica is present here