TsgcWebSocketHTTPServerProperties › QueueOptions

QueueOptions Property

Serialises outbound messages through an internal per-connection queue to prevent contention between threads.

Syntax

property QueueOptions: TsgcWSQueueServer_Options read FQueueOptions write SetQueueOptions;

Default Value

Text.Level=qmNone, Binary.Level=qmNone, Ping.Level=qmNone

Remarks

When enabled, messages are placed in an internal queue and sent in the context of the connection thread instead of the caller's thread — this removes the locking needed when several threads write to the same connection simultaneously. Each message type (Text, Binary, Ping) is a sub-object with its own Level property, which assigns an independent priority: qmNone skips the queue (default), qmLevel0 is processed first, then qmLevel1 and finally qmLevel2. For example, setting Text.Level and Binary.Level to qmLevel2 and Ping.Level to qmLevel1 guarantees pings are delivered before ordinary traffic. QueueOptions is only supported by the default IOHandler. When IOHandlerOptions.IOHandlerType is iohIOCP or iohEPOLL the queue is switched off as the server starts: the three levels are reset to qmNone, the OnError event reports it, and messages are written inline on the caller thread. A level assigned after the server is already listening is reset the same way on every new connection.

Example


oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.QueueOptions.Text.Level := qmLevel2;
oServer.QueueOptions.Binary.Level := qmLevel2;
oServer.QueueOptions.Ping.Level := qmLevel1;
oServer.Active := true;

Back to Properties