TsgcWSPClient_WAMP › Events › OnBinary
Fires when the server sends a binary WebSocket frame that is not part of the standard WAMP v1 text protocol.
property OnBinary: TsgcWSBinaryEvent;
// TsgcWSBinaryEvent = procedure(Connection: TsgcWSConnection; const Data: TMemoryStream) of object
—
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.
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;