TsgcWebSocketProxyServer › 事件 › OnBinary

OnBinary 事件

每次下游 WebSocket 客户端发送二进制消息时、代理将其转发至上游之前触发。

语法

property OnBinary: TsgcWSBinaryEvent;
// TsgcWSBinaryEvent = procedure(Connection: TsgcWSConnection; const Data: TMemoryStream) of object

默认值

—

备注

OnBinary 在从下游 WebSocket 客户端接收到完整二进制载荷并完成缓冲后触发一次。代理在处理程序返回后立即将此载荷中继到上行 TCP 服务器。

示例


procedure OnBinary(Connection: TsgcWSConnection; const Data: TMemoryStream);
var
  oBitmap: TBitmap;
begin
  oBitmap := TBitmap.Create;
  try
    oBitmap.LoadFromStream(Data);
    Image1.Picture.Assign(oBitmap);
  finally
    FreeAndNil(oBitmap);
  end;
end;

返回事件