TsgcWebSocketLoadBalancerServer事件 › OnFragmented

OnFragmented 事件

当负载均衡器在其某个会话上接收到分片 WebSocket 帧时触发。

语法

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

默认值

备注

OnFragmented 继承自底层 HTTP/WebSocket 服务器,对于直接由负载均衡器终止的连接上收到的每个分片帧都会触发。Data 是分片负载,OpCode 标识原始消息是文本还是二进制,Continuation 对于第一个分片之后的每个分片为 True。通过 Options.FragmentedMessages 启用此事件。对于被转发到后端的会话上的分片,请改为处理 OnClientFragmented,该事件还公开了转发器使用的 Handled 标志。

示例


procedure OnFragmented(Connection: TsgcWSConnection; const Data: TMemoryStream;
  const OpCode: TOpCode; const Continuation: Boolean);
begin
  Log(Format('Fragment: op=%d cont=%s size=%d',
    [Ord(OpCode), BoolToStr(Continuation, True), Data.Size]));
end;

返回事件