TsgcWebSocketClient属性 › QueueOptions

QueueOptions 属性

将出站 Text、Binary 和 Ping 消息排队,以便在连接线程上串行发送。

语法

property QueueOptions: TsgcWSQueueClient_Options read FQueueOptions write SetQueueOptions;

默认值

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

备注

默认情况下,消息直接在调用线程上写入。指定队列级别(qmLevel1qmLevel2qmLevel3)后,消息将入队并从连接线程依次发送,避免多个线程同时调用 WriteDataPing 时产生锁竞争。qmLevel1 的消息在 qmLevel2 之前处理,qmLevel2qmLevel3 之前处理,因此优先级较高的类别(例如 ping)可先于有效载荷传递。

MaxQueueSize 限制队列可容纳的消息数量:零(默认值)表示不设上限,保持以前的行为。达到上限时,OverflowPolicy 决定新消息的处理方式:qopDropOldest(默认值)丢弃队列中最旧的消息以腾出空间,qopDropNewest 丢弃新消息,qopDisconnect 丢弃新消息并关闭连接。每次达到上限时,都会先触发 OnSendBufferFull 事件,使应用程序能够监控背压或覆盖丢弃行为。

示例


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;

返回属性