triplem
(triple-m)
August 12, 2020, 7:04am
1
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 10.0.0.1481
Thanks
Werner
Edit: how could one quote delphi code inside a topic?
EvgenyK
(Evgeny Karpov)
August 12, 2020, 8:37am
2
Hi,
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);
begin
end;
initialization
RegisterEventSink(IUpdateEvents);
put delphi code inside ``` like
```
delphicode
```
triplem
(triple-m)
August 12, 2020, 2:39pm
4
Sorry, i was to fast
with your above suggestion compiler says: incomatible types: ‘IROEventSink’ and ‘TGUID’.
Whats wrong?
EvgenyK
(Evgeny Karpov)
August 12, 2020, 3:14pm
5
Hi,
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
triplem
(triple-m)
August 13, 2020, 5:11am
6
Hi,
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…
EvgenyK
(Evgeny Karpov)
August 13, 2020, 8:37am
7
Hi,
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