RTC Forums
November 24, 2024, 04:33:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: AutoSessions, AutoSessionsPing & AutoLogin ?  (Read 4469 times)
hannesgw
RTC Expired
*
Posts: 11


« on: January 23, 2013, 01:18:27 PM »

Hi, if I will use AutoSessionsPing it's enough when it's look like this:

procedure TdmClientMain.cmMainPing(Sender: TRtcConnection; Data: TRtcValue);
begin
  Data.newFunction('Ping');
end;

or do I need:

procedure TdmClientMain.cmMainPing(Sender: TRtcConnection; Data: TRtcValue);
begin
  Data.newFunction('fPing');
  myRes:=Execute(False);
end;

and is it same using AutoLogin like this:

procedure TdmClientMain.cmMainLogin(Sender: TRtcConnection; Data: TRtcValue);
begin
  with Data.newFunction('Login') do
  begin
    asString['user'] := 'testUser';
    asString['pw'] := '123456';
  end;
end;


and another in which order the components (TRtcHttpClient, TRtcClientModule, TRtcServerModule) work

TRtcHttpClient.OnConnect;
TRtcHttpClient.OnConnecting;

TRtcClientModule.OnPing;
TRtcClientModule.OnLogin;
TRtcClientModule.OnSessionOpen;

TRtcServerModule.OnSessionOpen;


Thanks in advance!
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: January 23, 2013, 01:43:13 PM »

In the Ping and AutoLogin events, you should ONLY prepare the Data object. You should NOT make the remote function call yourself, because it will be made by the component triggering the event. In other words, there two event implementations are correct:

procedure TdmClientMain.cmMainPing(Sender: TRtcConnection; Data: TRtcValue);
begin
  Data.newFunction('Ping');
end;

procedure TdmClientMain.cmMainLogin(Sender: TRtcConnection; Data: TRtcValue);
begin
  with Data.newFunction('Login') do
  begin
    asString['user'] := 'testUser';
    asString['pw'] := '123456';
  end;
end;

This is the usual event execution order:

// OnConnecting is called before OnConnect
TRtcHttpClient.OnConnecting;
TRtcHttpClient.OnConnect;

// OnPing is called based on the timer, when there is no other data being transferred
TRtcClientModule.OnPing;

// OnLogin is called if there is no active Session when a new remote call has to be made
// This event is inserted just before the first remote call waiting to be sent
TRtcClientModule.OnLogin;

// On the Server, OnSessionOpen will be called when a Session is created
TRtcServerModule.OnSessionOpen;

// OnSessionOpen is called on the Client after the Server tells the Client it has a new Session
TRtcClientModule.OnSessionOpen;

Best Regards,
Danijel Tkalcec
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.