Products

Price/Order

Support

Partners

Testimonials

Test Results

About us

Contact
 How do i wait result from server?
Bottom
 
Total posts: 5
 Author How do i wait result from server?
Ju Yong Hyun

15.06.2006 23:39:40
Registered user
A Client calls a functon to server which takes a few seconds/minutes.
How do i wait result with application blocking?
Danijel Tkalcec [RTC]

15.06.2006 23:46:00
Registered user
Even though RTC SDK is designed arround non-blocking event-driven architecture and it would be better if you can implement your code to work non-blocking, you can use the WaitForCompletion method (rtcHttpClient and rtcClientModule component have it) to wait for your calls to complete before continuing with execution.

Also, if you want all your calls to be blocking, you can set the "useProxy" property of your rtcHttpClient component to true. That will use the WinInet connection provider, which is blocking.
Muneer Said

08.01.2007 15:19:30
Registered user
I have the same issue.  I would like to block and wait for the result in the same function call.  For example:

function TDM.pingServer : Boolean;
begin
  with clientModule do
  begin
    with Data.NewFunction('ping') do
      Call( pingResult );  // <<<<<<<<- I DO NOT want to process the result in pingResult
    WaitForCompletion(true);
    // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<- I Would like to process the Result Here !
    result := functionResult.asBoolean;  // <<- Something like this  
  end;
end;

Is this Possible?

Reagrds,

MS.
Danijel Tkalcec [RTC]

08.01.2007 15:34:39
Registered user
This is possible if you use a global TRtcValue object, to which you would "move" the result from your OnResult event, so you can access it from somewhere else.

To do this, define one global variable in your Form, for example ...
var FunctionResult:TRtcValue;
Then create that object (container) from your application once (for example, in your OnFormCreate event), like this ...
FunctionResult:=TRtcValue.Create;
Then, in your RtcResult's "OnReturn" event, you can move the Result data you received from the Server to your global "FunctionResult" variable, like this ...
FunctionResult.asObject:=Result.asObject;
Result.asObject:=nil;
This will "move" the data from the "Result" parameter - which you have received in the OnResult event - to your global "FunctionResult" variable. Once you have done that, you will have access to all your Result data from outside of that event, so you can do what you wrote in your code above ...
function TDM.pingServer : Boolean;
begin
  with clientModule do
  begin
    with Data.NewFunction('ping') do
      Call( pingResult );  // <<<<<<<<- I DO NOT want to process the result in pingResult
    WaitForCompletion(true);
    // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<- I Would like to process the Result Here !
    result := functionResult.asBoolean;  // <<- Something like this  
    // when done using the "FunctionResult" object, clear it from memory ...
    functionResult.Clear;
  end;
end;

PS. It is necessary to do it like that and not any other way, because you need to "extract" the data from the "Result" object, or it would be destroyed otherwise, together with the whole "Result" object - which is temporary and was created only to hold the data received from the Server, and will exist only inside that OnResult event.

Best Regards,
Danijel Tkalcec
Muneer Said

08.01.2007 16:03:26
Registered user
Thanks, that works perfect.