RTC Forums
November 24, 2024, 09:44:01 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: OnPing event on the HTTPServer?  (Read 5585 times)
zxplzzc
RTC Expired
*
Posts: 8


« on: November 15, 2011, 02:55:36 AM »

I want to exchange simple data through the automatic OnPing event on the client,but it seemed that I can't find the peer on the http server,is it right?
Thanks!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: November 15, 2011, 04:16:53 AM »

There is no special "OnPing" event on the Server, because default PING calls do not send any data to the Server and you have full control over the "Data" object when using the "OnPing" event on the Client. This way, you can call any function on the Server you want.

For example, if you want to use the "OnPing" event on the Client to call a remote function on the Server called "PingMe", simply place the following code inside the "OnPing" event on the Client (TRtcClientModule component) ...

with Data.newFunction('PingMe') do
  begin
  // prepare all parameters for the "PingMe" function
  // asInteger['testPar1']:=12345;
  // asString['par2']:='This is a test';
  end;

When you do this, the "PingMe" remote function will be called on the Server every time a PING request is sent. In other words, the OnExecute event of the TRtcFunction with FunctionName="PingMe" will be executed, the same way it would be if you were calling the function using Call or Execute methods.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: November 15, 2011, 04:34:49 AM »

By the way ... the purpose of the "OnPing" event is to keep the Server-side Sessions alive. Because every remote function call will do the same (keep the Session for that Client alive), waiting timer for the next OnPing event will be reset every time a new remote function call is made, so a PING call will ONLY be made if there were no remote function calls made for longer than your specified AutoSessionsPing interval (seconds).

In other words, the automatic PING feature of the TRtcClientModule is NOT just a periodical remote function call. If other remote function calls are being made using the same TRtcClientModule component, the OnPing event will NOT be used in order to avoid generating unnecessary traffic. If you need your code on the Server to be executed periodically, even if other remote function calls are being made, then you should use a Timer component instead and send your remote calls directly (not through the OnPing event).

Best Regards,
Danijel Tkalcec
Logged
zxplzzc
RTC Expired
*
Posts: 8


« Reply #3 on: November 15, 2011, 08:16:11 AM »

Your answer is always so quick,clear,patient and pleasant.
Thanks very much!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.