TsgcWSPClient_WAMPEvents › OnBinary

OnBinary Event

Fires when the server sends a binary WebSocket frame that is not part of the standard WAMP v1 text protocol.

Syntax

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

Default Value

Remarks

WAMP v1 is a JSON-over-text protocol, so binary frames are not part of the specification. This handler surfaces any binary payload the server may send for application-specific reasons (file transfers, custom extensions, out-of-band telemetry). The stream position is at zero on entry and the buffer is owned by the component — copy the bytes out of Data before the handler returns.

Example


procedure TForm1.WAMPBinary(Connection: TsgcWSConnection;
  const Data: TMemoryStream);
var
  vBytes: TBytes;
begin
  SetLength(vBytes, Data.Size);
  Data.ReadBuffer(vBytes[0], Data.Size);
  Memo1.Lines.Add(Format('binary frame: %d bytes', [Length(vBytes)]));
end;

Back to Events