RTC Forums

Subscription => Support => Topic started by: hannesgw on January 23, 2013, 01:18:27 PM



Title: AutoSessions, AutoSessionsPing & AutoLogin ?
Post by: hannesgw 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!


Title: Re: AutoSessions, AutoSessionsPing & AutoLogin ?
Post by: D.Tkalcec (RTC) 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