TsgcWSPServer_sgc › 事件 › OnFragmented
从客户端接收的每个分片 WebSocket 消息的分片触发一次。
property OnFragmented: TsgcWSFragmentedEvent;
// TsgcWSFragmentedEvent = procedure(Connection: TsgcWSConnection; const Data: TMemoryStream; const OpCode: TOpCode; const Continuation: Boolean) of object
—
每个 RFC 6455 片段触发一次。OpCode 标记第一个片段(opText 或 opBinary),后续片段以 opContinuation 到达。Continuation 在有更多片段待接收时为 True,在最后一个片段时为 False。分配处理程序后,重组、解码以及 OnMessage/OnBinary 分发将被跳过,因此应用程序完全负责收集片段。
procedure TForm1.oProtocolFragmented(Connection: TsgcWSConnection;
const Data: TMemoryStream; const OpCode: TOpCode; const Continuation: Boolean);
begin
Memo1.Lines.Add(Format('fragment: %d bytes, more=%s',
[Data.Size, BoolToStr(Continuation, True)]));
end;