服务端代码:

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学习(一)的更多相关文章

  1. RealThinClient SDK 学习笔记(1)

    从客户端调用远程函数的两种方法 1: RtcClientModule1.Prepare('select'); // call the "select" function on th ...

  2. 从直播编程到直播教育:LiveEdu.tv开启多元化的在线学习直播时代

    2015年9月,一个叫Livecoding.tv的网站在互联网上引起了编程界的注意.缘于Pingwest品玩的一位编辑在上网时无意中发现了这个网站,并写了一篇文章<一个比直播睡觉更奇怪的网站:直 ...

  3. Angular2学习笔记(1)

    Angular2学习笔记(1) 1. 写在前面 之前基于Electron写过一个Markdown编辑器.就其功能而言,主要功能已经实现,一些小的不影响使用的功能由于时间关系还没有完成:但就代码而言,之 ...

  4. ABP入门系列(1)——学习Abp框架之实操演练

    作为.Net工地搬砖长工一名,一直致力于挖坑(Bug)填坑(Debug),但技术却不见长进.也曾热情于新技术的学习,憧憬过成为技术大拿.从前端到后端,从bootstrap到javascript,从py ...

  5. 消息队列——RabbitMQ学习笔记

    消息队列--RabbitMQ学习笔记 1. 写在前面 昨天简单学习了一个消息队列项目--RabbitMQ,今天趁热打铁,将学到的东西记录下来. 学习的资料主要是官网给出的6个基本的消息发送/接收模型, ...

  6. js学习笔记:webpack基础入门(一)

    之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...

  7. Unity3d学习 制作地形

    这周学习了如何在unity中制作地形,就是在一个Terrain的对象上盖几座小山,在山底种几棵树,那就讲一下如何完成上述内容. 1.在新键得项目的游戏的Hierarchy目录中新键一个Terrain对 ...

  8. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  9. 菜鸟Python学习笔记第一天:关于一些函数库的使用

    2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...

随机推荐

  1. java.lang.NoClassDefFoundError: org/apache/lucene/analysis/synonym/SynonymFilter

    2013-6-24 13:28:51 org.apache.solr.common.SolrException log 严重: java.lang.NoClassDefFoundError: org/ ...

  2. linux c setitimer使用方法说明

    在linux c编程中.setitimer是一个比較经常使用的函数.可用来实现延时和定时的功能,网上有各种零零散散的使用方法说明,都仅仅提到了个别使用方法,今天抽出时间实践整理了一份比較具体的: 使用 ...

  3. FastReport 数据过滤

    FastReport 数据过滤 在DataBind 的 OnBeforePrint 设置条件   例:显示 大于0 的数据 procedure MasterData1OnBeforePrint(Sen ...

  4. <Win32_12>程序员求爱的创意程序——升级版^_^

    前段时间,我编写了一个创意程序,并用于向自己目前的女朋友表白,结果效果还不错,得到了她的芳心. 于是我将自己的创意程序共享到csdn资源上,大多数网友认为创意不错,就是简单了些——呵呵,其实我个人也这 ...

  5. JCL学习

    JCL基本概念 定义:job control language 用户与操作系统的接口,用户通过JCL语句按照自己的意图来控制作业的执行. JOB的概念:把大机要实现的每一项任务,称为一个JOB或作业. ...

  6. java对象占用内存大小计算方式

    案例一: User public class User { } UserSizeTest public class UserSizeTest { static final Runtime runTim ...

  7. c# 未能载入文件或程序集

    近期做项目时碰到这个问题了.goole.百度了半天,整理了下面几种可能: DLL文件名称与载入时的DLL文件名称不一致, DLL文件根本不存在,即出现丢失情况, 载入DLL路径错误,即DLL文件存在, ...

  8. Bitmap Style Designer非官方说明

    Bitmap Style Designer Bitmap Style Designer给我的第一印象就是简陋,估计也是为了赶工.大致体会了一下,还是能够使用.因为目前没有对此有比较详细的中文资料,就把 ...

  9. 【C语言】超大数乘法运算

    昨天做排列组合的时候遇到A(a,b)这个问题,需要计算A(20,20)超大,计算机32位的,最大数只能是2^32,这让我很悲伤! 于是乎就自己研究了如何进行超大数的计算! /************* ...

  10. js正则验证手机号码有效性

    验证130-139,150-159,180-189号码段的手机号码 <script type="text/javascript"> [-]{})|([-]{})|([- ...