TsgcWebSocketServer_HTTPAPI › Properties › QueueOptions
通过内部每连接队列序列化出站消息,以防止线程间的竞争。
property QueueOptions: TsgcWSQueueServer_Options read FQueueOptions write SetQueueOptions;
Text=qmNone,Binary=qmNone,Ping=qmNone
启用后,消息被放入内部队列,并在连接线程的上下文中发送,而非在调用方线程中发送。这消除了多个线程同时向同一连接写入时所需的锁定。每种消息类型(Text、Binary、Ping)可以分配独立的优先级别:qmNone 跳过队列(默认),qmLevel1 最先处理,然后是 qmLevel2,最后是 qmLevel3。例如,将 Text 和 Binary 设为 qmLevel2,将 Ping 设为 qmLevel1,可保证 ping 先于普通流量传递。
oServer := TsgcWebSocketServer_HTTPAPI.Create(nil);
oServer.QueueOptions.Text := qmLevel2;
oServer.QueueOptions.Binary := qmLevel2;
oServer.QueueOptions.Ping := qmLevel1;
oServer.Active := true;