TWebSocketAsyncServer使用
TWebSocketAsyncServer使用
TWebSocketAsyncServer是MORMOT2异步WEBSOCKET服务端。
/// <author>cxg 2023-1-24</author> unit Unit1; interface uses mormot.net.http, mormot.net.ws.async, mormot.net.ws.core, System.Classes, Vcl.Controls, vcl.Forms, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } ws: TWebSocketAsyncServer; function process(Ctxt: THttpServerRequestAbstract): cardinal; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin var port: string := '9900'; var ThreadPoolCount: Integer := 32; var KeepAliveTimeOut: Integer := 30000; ws := TWebSocketAsyncServer.Create(port, nil, nil, 'yn', ThreadPoolCount, KeepAliveTimeOut); var Protocol: TWebSocketProtocol := TWebSocketProtocol.Create('yn', ''); ws.WebSocketProtocols.Add(Protocol); ws.OnRequest := process; ws.WaitStarted(); end; function TForm1.process(Ctxt: THttpServerRequestAbstract): cardinal; begin end; end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/17066187.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
2021-01-24 微服务概念讲解
2021-01-24 使用multipart打造rest粗接口