TWebSocketClient

支持WEBSOCKET通讯协议的客户端控件。

连接WEBSOCKET SERVER的代码演示:

WebSocketClient1.HostName := '88.198.69.227';
WebSocketClient1.Port := 8888;

WebSocketClient1.Disconnect;

WebSocketClient1.Connect;

接收数据事件:

procedure TForm43.WebSocketClient1DataReceived(Sender: TObject; Origin: string;
Data: TJSObject);
var
it: TTMSFNCListBoxItem;
sl: TStringList;
s: String;
n: string;
v: string;
begin
lst.BeginUpdate;
it := lst.Items.Add;
s := Data.toString;
sl := TStringList.Create;
try
TTMSFNCUtils.Split('~', s, sl);
if sl.Count > then
begin
n := '<font color="'+sl[]+'" size="16">'+sl[];
v := sl[];
it.Text := n + ' says: </font><font size="16">' + v+'</font>';
end;
finally
sl.Free;
end;
lst.EndUpdate;
end;

发送数据演示:

procedure TForm43.SendMessage;
var
s: string;
begin
if FConnected and (WebEdit2.Text <> '') then
begin
s := TTMSFNCGraphics.ColorToHTML(TMSFNCColorPicker1.SelectedColor) + '~' + WebEdit1.Text + '~' + WebEdit2.Text;
// limit message length
s := Copy(s,1,256);
WebSocketClient1.Send(s);
WebEdit2.Text := '';
end;
end;

  

TWebSocketClient的更多相关文章

随机推荐

  1. 解决cef中title不现实tooltip的问题

    本文转自:https://blog.csdn.net/hu1340748/article/details/79030569 感谢感谢 最近在使用chromiumFX做项目,突然发现页面标签中的titl ...

  2. vs2017 Remote Debugger远程调试目录

    默认目录:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Remote Debugger

  3. Linux系统产生随机数/dev/random 和 /dev/urandom

    1.  基本介绍 /dev/random和/dev/urandom是Linux系统中提供的随机伪设备,这两个设备的任务,是提供永不为空的随机字节数据流.很多解密程序与安全应用程序(如SSH Keys, ...

  4. public private protect

    public 公有  使用public意味着声明public之后的成员对每个人都是可用的 private 私有  除非必须公开底层实现细目,否则就应该将所有的域指定为private protect 继 ...

  5. vs2010 快捷键

    我自己的快捷键: visual studio 2010快捷键: visual studio 2010快捷键: 强迫智能感知:Ctrl+J撤销:Ctrl+Z强迫显示参数信息:Ctrl+Shift+空格重 ...

  6. Shell 利用 curl 模拟登陆

    -b 参数 指定使用cookie文件 -c是往cookie文件中写cookie -d 是指定此次登录所需的参数,通过httpfox查看 -L 指定页面自动跳转 #curl -c ck.txt --us ...

  7. C语言:逻辑推理

    1A.B.C.D.E五名学生有可能参加计算机竞赛,根据下列条件判断哪些(10分) 题目内容:   A.B.C.D.E五名学生有可能参加计算机竞赛,根据下列条件判断哪些 人参加了竞赛: (1)A参加时, ...

  8. 【AtCoder】ARC090

    C - Candies 前一枚举一个i,求第一行的前i个和第二行从第n个到第i个 代码 #include <bits/stdc++.h> #define fi first #define ...

  9. 主动学习——active learning

    阅读目录 1. 写在前面 2. 什么是active learning? 3. active learning的基本思想 4. active learning与半监督学习的不同 5. 参考文献   1. ...

  10. django URLconf调度程序

    路由的编写方式是Django2.0和1.11最大的区别所在,Django官方迫于压力和同行的影响,不得不将原来的正则匹配表达式,改为更加简单的path表达式,但依然通过re_path()方法保持对1. ...