RTC Forums
November 25, 2024, 12:50:07 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: About TRtcClientModule.Call(params)  (Read 6286 times)
pppp0831
Guest
« on: May 06, 2010, 09:40:39 AM »

hello ,guys
 i ve a question
   what kind of course  the Client call Server 's Funtions
          eg. Data.NewFunction('SrvTime') ;prepare to call srv's Srvtime
                Call(RtcResult1,True or false ,TRtcConnection or nil) ;Assign RtcResult1
            that 's it :
                           1. FromIsideEent : if enable True,Helpfiles said  the function we will call is inside anotherfunction ,Does it mean Are these nesting  functions ?
                          2.Sender: TRtcConnection   what wil it do?             
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: May 06, 2010, 09:44:23 AM »

<Quote from RTC SDK source code>
      If you are calling a remote function from inside other remote functions event,
      "FromInsideEvent" parameter has to be TRUE to avoid memory consumption and
      you should pass the Sender:TRtcConnection parameter to the Call() method.
</Quote>

Best Regards,
Danijel Tkalcec
Logged
pppp0831
Guest
« Reply #2 on: May 06, 2010, 10:03:30 AM »

thanks for ur reply ,i ve read this help file ,but i can understand this sentence
server:
 procedure TAppSrv_Module.AddFuncExecute(Sender:TRtcConnection;Param:TRtcFunctionInfo;Result:TRtcValue);
       function Add_1(A,B:integer)
           begin
               Result:=A+B;
            end;
begin
   result.asinteger:=0
end;
client:
 Data.NewFunction('Add');
 Call(TRtcResult1,True)  ;// cal Add_1?l
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: May 06, 2010, 10:11:50 AM »

I see you are missing the basic concepts of RTC remote functions.

How to write RTC Remote functions (Server side)?

How to call RTC Remote functions (Client side)?

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


« Reply #4 on: May 06, 2010, 10:38:12 AM »

And in your specific example, writing a remote function which would receive 2 integer parameters ("A" and "B") and return 1 integer parameter as a result, the server side code could look like ...

Server side:

procedure TAppSrv_Module.AddFuncExecute(Sender:TRtcConnection;Param:TRtcFunctionInfo;Result:TRtcValue);
  begin
  // All parameters received from the Client will be received in "Param" object
  // and the Result needs to be prepared using the "Result" object.
  Result.asinteger := Param.asInteger['A'] + Param.asInteger['B'];
  end;

The client side takes a bit more coding and there are two approaches. Blocking and event-driven ...

Client side:

Version (A) using blocking calls on the client side ...

with ClientModule do
  begin
  with Data.newFunction('Add') do
    begin
    asInteger['A']:=5;
    asInteger['B']:=10;
    end;
  Execute;
  A_plus_B := LastResult.asInteger;
  end;

Version (B) using event-driven approach, where you will use the "MyRtcResult" component to receive the result asynchronously (when it arrives) ...

with ClientModule do
  begin
  with Data.newFunction('Add') do
    begin
    asInteger['A']:=5;
    asInteger['B']:=10;
    end;
  Call(MyRtcResult);
  end;

... and then write the "OnResult" event of the "MyRtcResult" component like ...

  begin
  A_plus_B := Result.asInteger;
  end;

Please note that you do NOT have to write any events when using the blocking (A) approach. You also do NOT need TRtcResult components when using blocking approach. You need the TRtcResult component with at least the OnResult event implemented ONLY if you want to use the event-driven approach as explained in (B).

I hope this explains the basics.

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 16 queries.