How to sync timer event in server with client calls?

Hi! I have a RO server written by a former colleague which uses the TROSynchronizedSingletonClassFactory in order to serialize client calls. This is needed since the server calls a text-to-speech API for which there is a single channel license. Now I want to implement a timer-controlled “self-test” of the API connection from within the server. From initial tests, it seems like the TTimer events and the client calls are executed in different threads, which leads to problems when performed simultaneously. Is there any easy way to synchronize/serialize the “self test” with the client calls (without introducing a critical section and using this in every client method and in the timer event)? Any suggestions (including “out of the box” thinking!) are appreciated. Using Delphi XE7 / RO 8.3.93.1183.

Best regards

Magnus Oskarsson

you can use AsyncEx interface: in this way each asynchronous request will be executed one behind another only when channel isn’t busy.
Note: this won’t work with super channels that are asynchronous internally.

Also you can cancel requests in queue.
See Phone Photo Server example for details.

Hi Evgeny and thanks for your reply! Before I read it, I found a method in the RemObjects interface that suited my needs for the text-to-speech API test, so I simply made a client call from within the server “to itself”, and this had the desired effect of synchronizing/serializing. I will check your suggestions later if I have the time.

/Magnus