feat(batch26): implement websocket frame/core feature group A
This commit is contained in:
@@ -26,6 +26,7 @@ using ZB.MOM.NatsNet.Server.Auth;
|
||||
using ZB.MOM.NatsNet.Server.Internal;
|
||||
using ZB.MOM.NatsNet.Server.Internal.DataStructures;
|
||||
using ZB.MOM.NatsNet.Server.Protocol;
|
||||
using ZB.MOM.NatsNet.Server.WebSocket;
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server;
|
||||
|
||||
@@ -113,6 +114,7 @@ public sealed partial class ClientConnection
|
||||
// Client options (from CONNECT message).
|
||||
internal ClientOptions Opts = ClientOptions.Default;
|
||||
internal Route? Route;
|
||||
internal WebsocketConnection? Ws;
|
||||
|
||||
// Flags and state.
|
||||
internal ClientFlags Flags; // mirrors c.flags clientFlag
|
||||
@@ -1484,10 +1486,26 @@ public sealed partial class ClientConnection
|
||||
|
||||
internal (List<OutboundChunk> chunks, long attempted) CollapsePtoNB()
|
||||
{
|
||||
var chunks = OutNb;
|
||||
if (Ws != null && Ws.Frames.Count > 0)
|
||||
{
|
||||
chunks = [..OutNb];
|
||||
foreach (var frame in Ws.Frames)
|
||||
chunks.Add(new OutboundChunk(frame, frame.Length));
|
||||
Ws.Frames.Clear();
|
||||
Ws.FrameSize = 0;
|
||||
}
|
||||
|
||||
if (Ws is { CloseSent: true, CloseMessage: not null } && OutPb == Ws.CloseMessage.Length)
|
||||
{
|
||||
chunks = [..chunks, new OutboundChunk(Ws.CloseMessage, Ws.CloseMessage.Length)];
|
||||
Ws.CloseMessage = null;
|
||||
}
|
||||
|
||||
long attempted = 0;
|
||||
foreach (var chunk in OutNb)
|
||||
foreach (var chunk in chunks)
|
||||
attempted += chunk.Count;
|
||||
return (OutNb, attempted);
|
||||
return (chunks, attempted);
|
||||
}
|
||||
|
||||
internal bool FlushOutbound()
|
||||
@@ -1784,7 +1802,7 @@ public sealed partial class ClientConnection
|
||||
// =========================================================================
|
||||
|
||||
internal bool IsMqtt() => false; // Deferred to session 22 (MQTT).
|
||||
internal bool IsWebSocket() => false; // Deferred to session 23 (WebSocket).
|
||||
internal bool IsWebSocket() => Ws != null;
|
||||
internal bool IsHubLeafNode() => false; // Deferred to session 15 (leaf nodes).
|
||||
internal string RemoteCluster() => string.Empty; // Deferred to sessions 14/15.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user