TsgcWebSocketLoadBalancerServerEvents › OnClientBinary

OnClientBinary Event

Fires when a binary frame is received from a downstream client before it is forwarded to the selected backend server.

Syntax

property OnClientBinary: TsgcWSLBServerBinaryEvent;
// TsgcWSLBServerBinaryEvent = procedure(Connection: TsgcWSConnection; Data: TMemoryStream; var Handled: Boolean) of object

Default Value

Remarks

OnClientBinary is raised for every binary WebSocket frame received from a balanced client on its way to the backend server. The Connection parameter is the downstream client session and Data is the binary payload (position 0, do not free). Set Handled to True to consume the frame in the load balancer and prevent it from being relayed to the backend; leave it False (default) to let the load balancer forward the frame unchanged. This is the right place to inspect, audit, or rewrite binary traffic, to short-circuit health-check style messages, or to drop payloads that should never reach backend servers.

Example


procedure OnClientBinary(Connection: TsgcWSConnection; Data: TMemoryStream;
  var Handled: Boolean);
begin
  // drop empty frames instead of forwarding them
  Handled := Data.Size = 0;
end;

Back to Events