TsgcWebSocketServerEvents › OnSendBufferFull

OnSendBufferFull Event

Fires when the outbound queue of a client connection 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 for a connection whose queue already holds MaxQueueSize messages, this event is raised with the affected Connection and 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 slow consumers before they exhaust server memory.

Example


procedure OnSendBufferFull(Connection: TsgcWSConnection; const QueueSize: Integer;
  var DropMessage: Boolean);
begin
  WriteLn('#slow consumer ' + Connection.Guid + ': ' + IntToStr(QueueSize) + ' messages queued');
end;

Back to Events