TsgcWebSocketProxyServer › 事件 › OnFragmented

OnFragmented 事件

从下游客户端收到消息片段时触发(仅当 Options.FragmentedMessages 为 frgAll 或 frgOnlyFragmented 时)。

语法

property OnFragmented: TsgcWSFragmentedEvent;
// TsgcWSFragmentedEvent = procedure(Connection: TsgcWSConnection; const Data: TMemoryStream; const OpCode: TOpCode; const Continuation: Boolean) of object

默认值

—

备注

默认情况下(Options.FragmentedMessages = frgOnlyBuffer),代理缓冲下游消息的分片,并在收到完整载荷后触发 OnMessage 或 OnBinary,然后转发到上游。将 FragmentedMessages 设为 frgOnlyFragmented,则每个分片触发一次 OnFragmented;设为 frgAll 则每个分片触发 OnFragmented,消息完整后再触发 OnMessage/OnBinary。Data 参数是包含当前分片字节的 TMemoryStream,OpCode 指示原始帧类型(文本、二进制、续帧等),Continuation 在还有更多分片时为 True,在最后一个分片时为 False。该事件适用于报告正在代理的大型上传进度。

示例


procedure OnFragmented(Connection: TsgcWSConnection; const Data: TMemoryStream;
  const OpCode: TOpCode; const Continuation: Boolean);
begin
  ShowProgress(Data.Size);
  if not Continuation then
    SaveStream(Data);
end;

返回事件