设为首页 加入收藏

TOP

Server calling functions on client(一)
2017-10-10 12:03:37 】 浏览:1646
Tags:Server calling functions client

 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 ...
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇RTC Remote Functions - working .. 下一篇XML-RPC vs. RTC Format

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目