TsgcWebSocketClientEvents › OnSendBufferFull

OnSendBufferFull Event

Fires when the outbound message queue has reached QueueOptions.MaxQueueSize, before the overflow policy is applied.

Syntax

property OnSendBufferFull: TsgcWSSendBufferFullEvent;
// TsgcWSSendBufferFullEvent = procedure(Connection: TsgcWSConnection; const QueueSize: Integer; var DropMessage: Boolean) of object

Default Value

Remarks

Only fires when message queuing is active and QueueOptions.MaxQueueSize is greater than zero: every time a message is about to be enqueued while the queue already holds MaxQueueSize messages, this event is raised with the current QueueSize. DropMessage arrives as True; leave it unchanged to let QueueOptions.OverflowPolicy decide what happens (qopDropOldest discards the oldest queued message, qopDropNewest discards the new message, qopDisconnect discards it and closes the connection), or set it to False to accept the message anyway and let the queue grow beyond the limit. Use this event to detect backpressure, for example to pause producers or log slow-consumer conditions.

Example


procedure OnSendBufferFull(Connection: TsgcWSConnection; const QueueSize: Integer;
  var DropMessage: Boolean);
begin
  WriteLn('#send buffer full: ' + IntToStr(QueueSize) + ' messages queued');
end;

Back to Events