Author |
Server calling functions on client |
Leif Uneus
09.01.2007 22:16:51
Registered user
|
In the documentations about RtcFunctionGroup it says : "When used by a RtcClientModule, it gives server the ability to call client-side functions as a result of client's function calls."
How is that accomplished on the server ?
// My server's MyFunction.OnExecute event
procedure TMyServerDataModule.MyFunctionExecute(
Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue);
begin
// At this point I need to call a function on the client
// Something like Call( MyClientResult) with some information to the client.
// Since this is non-blocking, tell the client I'm working on it.
Result.asString:= 'Work in progress ...';
end;
// My server's MyClientResult.OnReturn
procedure TMyServerDataModule.MyClientResultReturn(Sender: TRtcConnection; Data,
Result: TRtcValue);
begin
IF (Result.isType = rtc_Exception) OR
(Result.isType = rtc_Null)
THEN BEGIN
// Tell the client that the job failed
END
ELSE BEGIN
// Process the result
// Tell the client the result of the job
END;
end;
|
Glynn Owen [RTC]
10.01.2007 00:47:15
Registered user
|
The help for the TRtcFunctionGroup component says -
<quote>
To implement remote functions, you will need at least one FunctionGroup component and link one or more TRtcFunction components to it. Function Group provides the means to use function calls as parameters to other function calls from the same group. It is primarily used by the TRtcServerModule and TRtcClientModule components to hold implementations for their remote functions.
This FunctionGroup will provide direct access to:
1.) all functions which have this component as their ".Group" property set.
2.) all functions of all child RtcFunctionGroups, meaning: RtcFunctionGroup components which have this component assigned to their "ParentGroup" property.
3.) all functions of the RtcFunctionGroup which is directly assigned to this component's "HelperGroup" property, including its child components. It is safe to assign the same HelperGroup to function groups at different levels (child/parent groups).
</quote>
What this does is allow function calls to the server made by the client to use other functions that are on the server. Since function calls are also objects, it also allows you to send a function call from Servers OnExecute event back to the client as Server's result. As with any other Result sent from the Server back to the Client, it will NOT be sent back to the Server, but instead (after any functions placed in that result have been executed on the Client) the resulting object will be sent to the OnResult event of the Client.
Once MyFunctionExecute has assigned something to the Result, the function is done, so I guess that what you are looking for is some way to notify the client that some kind of lengthy process is in progress. Is that right?
Have you looked at the examples in the QuickStart folder?
HTH,
Glynn
|
Danijel Tkalcec [RTC]
10.01.2007 02:54:21
Registered user
|
Let me elaborate a bit on this ...
|
|