Test Results

About us

 Can Server call a function on the Client or ping the Client (reverse call)?
Total posts: 2
 Author Can Server call a function on the Client or ping the Client (reverse call)?
Danijel Tkalcec [RTC]

01.06.2006 21:37:00
Registered user
If you want your server to be able to send the data to your client when server wants, there is nothing special you need to do on the client side, except call a remote function and know that a result will come when there is data available, or when a time limit is expired.

After client receives a result (any kind), it should use a timer to post another call, to keep a connection open all-the-time at the server.

On the server side, you use PrepareDelayedCall from within your remote function’s OnExecute event to prepare a call and get an object, which you can use to wake the call later. Then, you use PostDelayedCall to go to a “sleep state”, which will be “broken” after the timeout expires (specified by using PrepareDelayedCall) or if you call the “WakeUp” method on the object you obtained from PrepareDelayedCall.

Using PrepareDelayedCall and PostDelayedCall is not complicated, but it could be a bit “tricky” if you want to be able to “wake the delayed call”, since you will have to store a temporary object and use if from somewhere else in your application.

I guess, the best place to start learning about using delayed calls with RTC SDK is looking at RTC Messenger Server’s remote function for “get msg”. Also, check the description for the TRtcDelayedCall class and description of PrepareDelayedCall, PostDelayedCall and CancelDelayedCall functions.
Danijel Tkalcec [RTC]

13.08.2006 12:28:31
Registered user
Here's another explanation ...

Your client can send remote calls to the Server to ask if the Server has something for the Client. The Client side is simple here. You can either use a timer to periodicaly issue a remote call, or ... you can send the next call from the OnResult event of your TRtcResult object. Either way, you will have an endless loop on the client side.

On the Server side, you can use DelayedCalls to enable the Server to respond when it has something to send. Using DelayedCalls, Server will put the remote function "to sleep" by specifying a timeout (after which the function will be "awaken" automaticaly) and getting an object using which you can wake the function up (when you got data to send back to the client).

Generaly, to implement the DelayedCalls approach, your Client will repeatedly send a remote call to the Server, Server will check if there is something it wants to send to the Client and if not, put the call to sleep, then (from your functions which prepare the data for your clients) wake the call up to signal that it has something to send to the Client.

RTC Messenger uses this approach to implement message dispatching between clients. This way, when a client sends a message to another client, it will be delivered instantly, even though clients are triggering "Get Message" calls once every 30 seconds (to avoid flooding the network).