RealThinClient学习(一)


服务端代码:
unit RtcHttpServer; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, StdCtrls, ComCtrls, rtcInfo, rtcConn, rtcDataSrv, rtcHttpSrv,
rtcFunction, rtcSrvModule; type
TMsgType = (mtOK, mtHelp, mtErr); TrtcHttpServerDemo = class(TForm)
RtcHttpServer1: TRtcHttpServer;
ListView1: TListView;
Button1: TButton;
Button2: TButton;
ImageList1: TImageList;
RtcFunctionGroup1: TRtcFunctionGroup;
RtcFunction1: TRtcFunction;
RtcServerModule1: TRtcServerModule;
procedure Button1Click(Sender: TObject);
procedure RtcHttpServer1Connect(Sender: TRtcConnection);
procedure RtcHttpServer1Connecting(Sender: TRtcConnection);
procedure RtcHttpServer1Disconnect(Sender: TRtcConnection);
procedure RtcHttpServer1ListenStart(Sender: TRtcConnection);
procedure RtcHttpServer1SessionClose(Sender: TRtcConnection);
procedure RtcHttpServer1SessionOpen(Sender: TRtcConnection);
procedure RtcHttpServer1ListenLost(Sender: TRtcConnection);
procedure RtcFunction1Execute(Sender: TRtcConnection;
Param: TRtcFunctionInfo; Result: TRtcValue);
private
procedure LogEvent(msg: String; msgType: TMsgType);
procedure LogClear;
public
{ Public declarations }
end; var
rtcHttpServerDemo: TrtcHttpServerDemo; implementation {$R *.dfm} procedure TrtcHttpServerDemo.Button1Click(Sender: TObject);
begin
//开始监听
RtcHttpServer1.Listen();
end; procedure TrtcHttpServerDemo.LogClear;
begin
//清除事件列表
ListView1.Items.Clear;
end; procedure TrtcHttpServerDemo.LogEvent(msg: String; msgType:TMsgType);
var
ltIco: TListItem;
begin
ltIco := ListView1.Items.Add;
ltIco.SubItems.Add(msg);
ltIco.SubItems.Add(DateTimeToStr(Now));
//设置图标
case msgType of
mtOK: ltIco.StateIndex := ;
mtHelp: ltIco.StateIndex := ;
mtErr: ltIco.StateIndex := ;
end; ListView1.Scroll(, );
end; procedure TrtcHttpServerDemo.RtcFunction1Execute(Sender: TRtcConnection;
Param: TRtcFunctionInfo; Result: TRtcValue);
begin
with Sender as TRtcDataServer do
begin
//请求名字
LogEvent('请求参数:' + Param.asString['name'], mtOK);
Result.asString := 'Hello: ' + Param.asString['name'];
end;
end; procedure TrtcHttpServerDemo.RtcHttpServer1Connect(Sender: TRtcConnection);
//连接事件
begin
LogEvent('连接成功:客户端地址:' + Sender.PeerAddr + ',当前客户端连接数'
+ IntToStr(Sender.TotalConnectionCount), mtOK); end; procedure TrtcHttpServerDemo.RtcHttpServer1Connecting(Sender: TRtcConnection);
begin
LogEvent(Sender.sPeerAddr + '正在连接中...', mtOk);
end; procedure TrtcHttpServerDemo.RtcHttpServer1Disconnect(Sender: TRtcConnection);
begin
LogEvent(Sender.sPeerAddr + '连接断开了... 当前客户端连接数'
+ IntToStr(Sender.TotalConnectionCount - ), mtOk);
end; procedure TrtcHttpServerDemo.RtcHttpServer1ListenLost(Sender: TRtcConnection);
begin
LogEvent('监听丢失:' + Sender.PeerAddr, mtErr);
end; procedure TrtcHttpServerDemo.RtcHttpServer1ListenStart(Sender: TRtcConnection);
begin
LogClear;
LogEvent('服务启动中',Mtok);
end; procedure TrtcHttpServerDemo.RtcHttpServer1SessionClose(Sender: TRtcConnection);
begin
LogEvent('会话已关闭',MtErr);
end; procedure TrtcHttpServerDemo.RtcHttpServer1SessionOpen(Sender: TRtcConnection);
begin
LogEvent('会话已成功连接',MtErr);
end; end.
客户端代码:
unit RtcClient; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, rtcConn, rtcDataCli, rtcHttpCli, rtcInfo, rtcFunction, StdCtrls,
ExtCtrls, ComCtrls, ImgList, rtcCliModule; type TMsgType = (mtOK, mtHelp, mtErr); TfrmRtcHttpClient = class(TForm)
RtcFunction1: TRtcFunction;
RtcHttpClient1: TRtcHttpClient;
ListView1: TListView;
Panel1: TPanel;
Button1: TButton;
ImageList1: TImageList;
RtcClientModule1: TRtcClientModule;
RtcFunctionGroup1: TRtcFunctionGroup;
Button2: TButton;
RtcResult1: TRtcResult;
edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure RtcHttpClient1ConnectError(Sender: TRtcConnection; E: Exception);
procedure RtcHttpClient1ConnectFail(Sender: TRtcConnection);
procedure RtcFunction1Execute(Sender: TRtcConnection;
Param: TRtcFunctionInfo; Result: TRtcValue);
procedure edit1KeyPress(Sender: TObject; var Key: Char);
procedure RtcResult1Return(Sender: TRtcConnection; Data, Result: TRtcValue);
procedure RtcHttpClient1Connect(Sender: TRtcConnection);
private
procedure LogEvent(msg: String; msgType: TMsgType);
procedure LogClear;
public
{ Public declarations }
end; var
frmRtcHttpClient: TfrmRtcHttpClient; implementation {$R *.dfm} procedure TfrmRtcHttpClient.Button1Click(Sender: TObject);
begin
if RtcHttpClient1.isConnected
or RtcHttpClient1.isConnecting then
exit;
RtcHttpClient1.Connect();
end; procedure TfrmRtcHttpClient.edit1KeyPress(Sender: TObject; var Key: Char);
begin
//发送请求
if key = # then begin
with RtcClientModule1, Data do
begin
with NewFunction('SimpleTest') do begin
asString['name'] := edit1.Text;
Call(RtcResult1);
end;
end;
end; end; procedure TfrmRtcHttpClient.LogClear;
begin
ListView1.Items.Clear;
end; procedure TfrmRtcHttpClient.LogEvent(msg: String; msgType: TMsgType);
var
ltIco, ltEvent, ltDate: TListItem;
begin
ltIco := ListView1.Items.Add;
ltIco.SubItems.Add(msg);
ltIco.SubItems.Add(DateTimeToStr(Now));
//设置图标
case msgType of
mtOK: ltIco.StateIndex := ;
mtHelp: ltIco.StateIndex := ;
mtErr: ltIco.StateIndex := ;
end; ListView1.Scroll(, );
end; procedure TfrmRtcHttpClient.RtcFunction1Execute(Sender: TRtcConnection;
Param: TRtcFunctionInfo; Result: TRtcValue);
begin
Param.asString['name'] := 'pengshaomin';
LogEvent('服务器响应:' + Result.asString, mtOK);
end; procedure TfrmRtcHttpClient.RtcHttpClient1Connect(Sender: TRtcConnection);
begin
LogEvent('连接服务器[' + Sender.sServerAddr +']成功', mtOK);
end; procedure TfrmRtcHttpClient.RtcHttpClient1ConnectError(Sender: TRtcConnection;
E: Exception);
begin
LogEvent('连接服务器[' + Sender.sServerAddr +']错误', mtErr);
end; procedure TfrmRtcHttpClient.RtcHttpClient1ConnectFail(Sender: TRtcConnection);
begin
LogEvent('连接服务器[' + Sender.sServerAddr +']失败', mtErr);
end; procedure TfrmRtcHttpClient.RtcResult1Return(Sender: TRtcConnection; Data,
Result: TRtcValue);
begin with Sender as TRtcDataClient do
begin
LogEvent( (Sender as TRtcDataClient).sServerAddr + '服务器:' + Result.asString, mtOK);
end;
end; end.
http://www.cnblogs.com/pengshaomin/archive/2012/10/10/2718579.html
RealThinClient学习(一)的更多相关文章
- RealThinClient SDK 学习笔记(1)
从客户端调用远程函数的两种方法 1: RtcClientModule1.Prepare('select'); // call the "select" function on th ...
- 从直播编程到直播教育:LiveEdu.tv开启多元化的在线学习直播时代
2015年9月,一个叫Livecoding.tv的网站在互联网上引起了编程界的注意.缘于Pingwest品玩的一位编辑在上网时无意中发现了这个网站,并写了一篇文章<一个比直播睡觉更奇怪的网站:直 ...
- Angular2学习笔记(1)
Angular2学习笔记(1) 1. 写在前面 之前基于Electron写过一个Markdown编辑器.就其功能而言,主要功能已经实现,一些小的不影响使用的功能由于时间关系还没有完成:但就代码而言,之 ...
- ABP入门系列(1)——学习Abp框架之实操演练
作为.Net工地搬砖长工一名,一直致力于挖坑(Bug)填坑(Debug),但技术却不见长进.也曾热情于新技术的学习,憧憬过成为技术大拿.从前端到后端,从bootstrap到javascript,从py ...
- 消息队列——RabbitMQ学习笔记
消息队列--RabbitMQ学习笔记 1. 写在前面 昨天简单学习了一个消息队列项目--RabbitMQ,今天趁热打铁,将学到的东西记录下来. 学习的资料主要是官网给出的6个基本的消息发送/接收模型, ...
- js学习笔记:webpack基础入门(一)
之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...
- Unity3d学习 制作地形
这周学习了如何在unity中制作地形,就是在一个Terrain的对象上盖几座小山,在山底种几棵树,那就讲一下如何完成上述内容. 1.在新键得项目的游戏的Hierarchy目录中新键一个Terrain对 ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- 菜鸟Python学习笔记第一天:关于一些函数库的使用
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
随机推荐
- stringstream clear()的疑问 - yuanshuilee的日志 - 网易博客
stringstream clear()的疑问 - yuanshuilee的日志 - 网易博客 stringstream clear()的疑问 2013-09-05 08:43:13| 分类: ...
- mysq Point类型 查询和插入操作:insert和select
首先,创建一个表名为geometry2的表,然后增加一个名为gemo的point类型的字段. insert方法有4中,例如以下所看到的://============================== ...
- POJ 2031 prim
Building a Space Station Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4400 Accepted: 2 ...
- DNS:因特网的目录服务
作者:华科小涛,http://www.cnblogs.com/hust-ghtao/ 有两种方式来识别主机:通过主机名或IP地址.人们当然喜欢便于记忆的主机名,而路由器则喜欢定长的.有层次结构的IP地 ...
- perl 函数回调 引用$client->run(sub {$client->sync});
匿名函数引用: [root@wx03 wx]# perl a1.pl CODE(0x2077b30) test [root@wx03 wx]# cat a1.pl $ref= sub {return ...
- Canvas上绘制几何图形
重要的类自定义View组件要重写View组件的onDraw(Canvase)方法,接下来是在该 Canvas上绘制大量的几何图形,点.直线.弧.圆.椭圆.文字.矩形.多边形.曲线.圆角矩形,等各种形状 ...
- C#、WinForm、ASP.NET - SQLHelper.cs
SQLHelper.cs using System; using System.Data; using System.Configuration; using System.Data.SqlClien ...
- 用Delphi进行word开发
使用以CreateOleObjects方式调用Word 实际上还是Ole,但是这种方式能够真正做到完全控制Word文件,能够使用Word的所有属性,包括自己编写的VBA宏代码.------------ ...
- GDI+: Curved Shapes
原文 http://www.functionx.com/vcsharp2003/gdi/curves.htm Curves Introduction to Curves A curve is ...
- 语音信号处理之(三)矢量量化(Vector Quantization)
语音信号处理之(三)矢量量化(Vector Quantization) zouxy09@qq.com http://blog.csdn.net/zouxy09 这学期有<语音信号处理>这门 ...