Title: About TRtcClientModule.Call(params) Post by: pppp0831 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? Title: Re: About TRtcClientModule.Call(params) Post by: D.Tkalcec (RTC) 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 Title: Re: About TRtcClientModule.Call(params) Post by: pppp0831 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 Title: Re: About TRtcClientModule.Call(params) Post by: D.Tkalcec (RTC) 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)? (http://www.realthinclient.com/sdkarchive/index44484448.html) How to call RTC Remote functions (Client side)? (http://www.realthinclient.com/sdkarchive/indexcacdcacd.html) Best Regards, Danijel Tkalcec Title: Re: About TRtcClientModule.Call(params) Post by: D.Tkalcec (RTC) 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 |