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有很多语言的 ...
随机推荐
- 什么是DNS劫持
我们知道,某些网络运营商为了某些目的,对DNS进行了某些操作,导致使用ISP的正常上网设置无法通过域名取得正确的IP地址.常用的手段有:DNS劫持和DNS污染. 什么是DNS劫持 DNS劫持就是通过劫 ...
- NEC协议
注意: 用示波器在接收头抓的电平看起来和NEC协议刚好相反, 那是因为:HS0038B 这个红外一体化接收头,当收到有载波的信号的时候,会输出一个低电平,空闲的时候会输出高电平. 具体情况,具体分析. ...
- VC++编程之字符串解惑--Unicode & MBCS
VC++中的字符串用起来着实让人难受,LPTSTR.LPCTSTR.LPCSTR.LPCWSTR.LPSTR.WCHAR.CString._T()和L彼此之间的互相转换更是头痛.根据使用经验和MSDN ...
- CentOS的ssh sftp配置及权限设置(流程相当完整)(关闭了SElinux才能上传了)
从技术角度来分析,几个要求: 1.从安全方面看,sftp会更安全一点 2.线上服务器提供在线服务,对用户需要控制,只能让用户在自己的home目录下活动 3.用户只能使用sftp,不能ssh到机器进行操 ...
- maven项目部署到Repository(Nexus)
目录[-] (一)下载并安装Nexus (二)配置Nexus Repository 说明: (三)在项目中配置Nexus Repository的信息 (四)发布到Nexus Repository 本文 ...
- js遍历对象的数组
遍历数组: 1.js关键for遍历 2.jquery提供each功能 ----------------------------------- $.each(array, function(){ ...
- <转载>DIV+CSS position定位方法总结
如何学习DIV+CSS布局之position属性 如果用position来布局页面,父级元素的position属性必须为relative,而定位于父级内部某个位置的元素,最好用 absolute. 任 ...
- Qt多工程多目录的编译案例
源地址:http://blog.csdn.net/libaineu2004/article/details/23625441 写这篇文章的目的是为了让Qt像VC++那样,支持一个工程包含多个项目.即1 ...
- 14.18 InnoDB Backup and Recovery 备份和恢复:
14.18 InnoDB Backup and Recovery 备份和恢复: 安全数据库管理的关键是 做定期的备份,依赖你的数据卷, MySQL server的数量和数据库的负载,你可以使用那些技术 ...
- 大数据高并发系统架构实战方案(LVS负载均衡、Nginx、共享存储、海量数据、队列缓存)
课程简介: 随着互联网的发展,高并发.大数据量的网站要求越来越高.而这些高要求都是基础的技术和细节组合而成的.本课程就从实际案例出发给大家原景重现高并发架构常用技术点及详细演练. 通过该课程的学习,普 ...