TsgcWebSocketHTTPServer › 属性 › Options
捆绑各种服务器行为标志:分片处理、超时、HTTP 测试页面和 UTF-8 验证。
property Options: TsgcWSOptionsServer read FOptions write SetOptions;
FragmentedMessages=frgOnlyBuffer,HTMLFiles=True,JavascriptFiles=True,ReadTimeOut=10,WriteTimeOut=0
FragmentedMessages 控制如何传递分片帧:frgOnlyBuffer(默认)会缓冲消息直至完整,并触发 OnMessage/OnBinary;frgOnlyFragmented 会为每个分片触发 OnFragmented;frgAll 两者都触发。HTMLFiles 和 JavascriptFiles 让服务器提供内置的浏览器测试页面和 JavaScript 客户端(默认启用)。RaiseDisconnectExceptions 在断开连接由协议错误引起时抛出异常。ReadTimeOut 是以毫秒为单位的轮询间隔(默认 10);WriteTimeOut 限制套接字写入在丢弃停滞客户端之前可以阻塞的时间(0 表示无限制),现在同时适用于 Windows 和 POSIX (Linux),这有助于防御原本会占用服务器线程的慢读客户端。ValidateUTF8 会拒绝包含无效 UTF-8 序列的文本消息(默认禁用)。Software 保存在 HTTP Server 标头中发送的值。
oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.Options.FragmentedMessages := frgOnlyBuffer;
oServer.Options.ValidateUTF8 := true;
oServer.Options.HTMLFiles := false;
oServer.Active := true;