TsgcWebSocketClient › Properties › QueueOptions

QueueOptions Property

Queues outgoing Text, Binary and Ping messages so they are serialised on the connection thread.

Syntax

property QueueOptions: TsgcWSQueueClient_Options read FQueueOptions write SetQueueOptions;

Default Value

Text.Level=qmNone, Binary.Level=qmNone, Ping.Level=qmNone, MaxQueueSize=0, OverflowPolicy=qopDropOldest, DrainedMode=qdmTransition

Remarks

By default messages are written directly on the caller thread. Assigning a queue level (qmLevel0, qmLevel1 or qmLevel2) enqueues them and sends them sequentially from the connection thread, avoiding locks when several threads call WriteData or Ping at once. Messages at qmLevel0 are processed before qmLevel1, and qmLevel1 before qmLevel2, so higher-priority categories (for example ping) can be delivered ahead of payloads.

MaxQueueSize bounds the number of messages a queue may hold: zero (default) means unbounded, keeping the previous behaviour. When the limit is reached, OverflowPolicy decides what happens with new messages: qopDropOldest (default) discards the oldest queued message to make room, qopDropNewest discards the new message, and qopDisconnect discards it and closes the connection. Each time the limit is hit the OnSendBufferFull event fires first, allowing the application to monitor backpressure or override the drop.

DrainedMode selects when the OnQueueDrained event is raised. With qdmTransition (default) the event fires once each time the outgoing queue of a connection goes from holding messages to being empty. With qdmEveryPass it fires on every pass of the connection loop, right after the queues are sent, even when the queue was already empty and even when Text.Level, Binary.Level and Ping.Level are all qmNone, so no dummy queue level is needed. It is useful as a per-connection hook that runs on the connection own thread, for example to send pending application data with WriteData. The event does not follow NotifyEvents, so the handler must be fast and must not touch the user interface. Each connection copies the queue options when it connects, so set DrainedMode before activating the component, connections already open keep the previous mode.

Example


oClient := TsgcWebSocketClient.Create(nil);
oClient.URL := 'wss://www.esegece.com:2053';
oClient.QueueOptions.Ping.Level := qmLevel1;
oClient.QueueOptions.Text.Level := qmLevel2;
oClient.QueueOptions.Binary.Level := qmLevel2;
oClient.Active := true;

Back to Properties