TsgcWebSocketLoadBalancerServerEvents › OnClientFragmented

OnClientFragmented Event

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

Syntax

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

Default Value

Remarks

OnClientFragmented is raised whenever the load balancer receives a fragmented WebSocket message from a client (enabled via Options.FragmentedMessages on the underlying server). Connection is the downstream session and Data holds the payload for the current fragment. Set Handled to True to consume the fragment in the load balancer and stop it from being forwarded to the backend; leave it False to have the load balancer relay the fragment unchanged. Typical usage is for lightweight inspection or filtering of very large uploads without reassembling the whole message.

Example


procedure OnClientFragmented(Connection: TsgcWSConnection; Data: TMemoryStream;
  var Handled: Boolean);
begin
  Log(Format('Fragment %d bytes from %s', [Data.Size, Connection.Guid]));
  Handled := False;
end;

Back to Events