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有很多语言的 ...
随机推荐
- haroxy hdr
ACL derivatives :ACL的衍生物 hdr([<name>[,<occ>]]) : exact string match 字符串精确匹配 hdr_beg([< ...
- Android Socket 开发技术
根据之前的经验,应用软件的网络通信无非就是Socket和HTTP,其中Socket又可以用TCP和UDP,HTTP的话就衍生出很多方式,基础的HTTP GET和POST请求,然后就是WebServic ...
- 它们的定义View
Ios"巷自己的定义View和Android类别似 在.h文件设置了他的一些财产.方法 在.m文件中实现 .h文件 #import <UIKit/UIKit.h> CGPoint ...
- linux head命令
head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾. 1.命令格式: hea ...
- 用Photoshop做圆角图片
如果图片被锁定,请“双击”图层中“背景”解锁,如果没有图层菜单,在最上面导航栏中:窗口—图层. 选用“圆角矩形工具“ 设置圆角弧度大小,设置“半径” 19 同时按Ctrl+回车(Enter)选区,再C ...
- Docker学习笔记(1) — docker 常用命令
1. docker version显示 Docker 版本信息.2. docker info显示 Docker 系统信息,包括镜像和容器数.3. docker searchdocker search ...
- 【linux】 Makefile之make menuconfig /uImage
欢迎转载,转载时请保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http: ...
- psl/sql本地与远程连接配置
一:下载Oracleclient 下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-09748 ...
- 一个能够自己主动生成静态库,自己主动安装程序的Makefile
.PHONY:clean install CC=g++ CFLAGS=-Wall -g BIN=libecho.a INCLUDE=echo SRC=src OBJS=Socket.o Rio.o T ...
- CodeForce 439C Devu and Partitioning of the Array(模拟)
Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...