RTC学习记录
1: 要让客户端在网络断开后自动连接到服务器需:
A:RTCHttpClient的ReconnectOn 属性需要设置
B:RTCHttpClient的AutoConnect属性必须为False (这个属性为True时,当没有建立连接时而Call远程函数,会自动连接)
2: 注意: 所有的RTCHttpServer和RTCHttpClient组件的事件都必须类似这样写代码(如):
procedure TForm1.RtcHttpServer1ListenStart(Sender: TRtcConnection);
begin
if not Sender.inMainThread then
Sender.Sync(RtcHttpServer1ListenStart);
btn1.Caption := '断开';
end;
if not Sender.inMainThread then
Sender.Sync(RtcHttpServer1ListenStop)
else
begin
btn1.Caption := '监听';
end;
主要是考虑多线程情况.
3: RtcServerModule/RtcClientModule的ModuleFileName属性为必填项.如输入:Test 会自动在前增加"/".
另:ModuleHost属性暂还没试验,看帮助大意是实现类似IIS主机头的的功能,实现不同的域名访问,还有待验证.
4: 调用没有参数的远程函数时必须先创建个TRtcFunctionInfo,由NewFunction创建
RtcClientModule1.StartCalls;
//RtcClientModule1.Data.NewFunction('ToDo').Value['szName'] := 'Handll';
RtcClientModule1.Data.NewFunction('ToDo');
RtcClientModule1.Call(RtcResult1);
RtcClientModule1.Post;
TRtcFunctionInfo应该是函数的参数对象,需要传递给服务器端.