TsgcWebSocketServer › Events › OnSendBufferFull
Fires when the outbound queue of a client connection has reached QueueOptions.MaxQueueSize, before the overflow policy is applied.
property OnSendBufferFull: TsgcWSSendBufferFullEvent;
// TsgcWSSendBufferFullEvent = procedure(Connection: TsgcWSConnection; const QueueSize: Integer; var DropMessage: Boolean) of object
—
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.
procedure OnSendBufferFull(Connection: TsgcWSConnection; const QueueSize: Integer;
var DropMessage: Boolean);
begin
WriteLn('#slow consumer ' + Connection.Guid + ': ' + IntToStr(QueueSize) + ' messages queued');
end;