打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
mormot支持websocket

mormot支持websocket

根据定义,HTTP连接是无状态的和单向的,也就是说,客户机向服务器发送一个请求,该服务器通过一个应答回复。
没有客户端的预先请求,就没有办法让服务器发送消息给客户机。

WebSockets是能让普通的HTTP连接升级为双路通信有线通信协议。
在安全握手之后,底层TCP/IP套接字能够通过一组轻量级协议直接访问应用程序定义的协议,而不需要HTTP开销。

synbidirsock.pas单元实现底层服务器和客户端WebSocket通信。

 

服务端:

uses mORMotHttpServer

 HttpServer := TSQLHttpServer.Create('8888',[Server],'+',useBidirSocket);
Under the hood, it will instantiate a TWebSocketServer HTTP server, as defined in mORMotHttpServer.pas, based on the sockets API, able to upgrade the HTTP protocol into WebSockets.
Our High-performance http.sys server is not yet able to switch to WebSockets - and at API level, it would require at least Windows 8 or Windows 2012 Server.

Then you enable WebSockets for the TWebSocketProtocolBinary protocol, with an encryption key:

   HttpServer.WebSocketsEnable(Server,'key');

客户端:
Client := TSQLHttpClientWebsockets.Create('127.0.0.1','8888',TSQLModel.Create([]));  Client.WebSocketsUpgrade('key');
除了常规的查询/应答命令定义客户端服务器的服务通过接口,还可以使用接口参数的服务定义回调方法。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Long
盘点3个支持http3的爬虫库
HTML5 postMessage 和 onmessage API 详细应用
深入认识Tigase XMPP Server(上)
WebSocket实战 | 新浪UED
http
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服