TsgcWebSocketLoadBalancerServerEvents › OnBinary

OnBinary Event

Fires when the load balancer itself receives a binary WebSocket frame on one of its downstream sessions.

Syntax

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

Default Value

Remarks

OnBinary is inherited from the underlying HTTP/WebSocket server and is raised when a complete binary frame is received on a connection terminated by the load balancer (for example a connection that was not forwarded because no backend was available, or one attached to a protocol handled directly by the LoadBalancer). The Data stream contains the payload and its position is 0; read it once and do not free it, the server owns the buffer. For data arriving on connections that are being proxied to a backend server use OnClientBinary instead, which exposes the per-client frame before it is forwarded.

Example


procedure OnBinary(Connection: TsgcWSConnection; const Data: TMemoryStream);
begin
  Log(Format('Received %d bytes from %s', [Data.Size, Connection.Guid]));
end;

Back to Events