feat: implement verbose mode (+OK after commands)

When a client sends CONNECT {"verbose":true}, the server now responds
with +OK\r\n after successfully processing CONNECT, PING, SUB, UNSUB,
and PUB/HPUB commands, matching the Go NATS server behavior.
This commit is contained in:
Joseph Doherty
2026-02-22 23:54:41 -05:00
parent bce793fd42
commit 04305447f9
2 changed files with 147 additions and 0 deletions

View File

@@ -235,6 +235,8 @@ public sealed class NatsClient : IDisposable
{
Interlocked.Exchange(ref _lastActivityTicks, DateTime.UtcNow.Ticks);
ProcessPub(cmd, ref localInMsgs, ref localInBytes);
if (ClientOpts?.Verbose == true)
WriteProtocol(NatsProtocol.OkBytes);
}
else
{
@@ -292,10 +294,14 @@ public sealed class NatsClient : IDisposable
{
case CommandType.Connect:
await ProcessConnectAsync(cmd);
if (ClientOpts?.Verbose == true)
WriteProtocol(NatsProtocol.OkBytes);
break;
case CommandType.Ping:
WriteProtocol(NatsProtocol.PongBytes);
if (ClientOpts?.Verbose == true)
WriteProtocol(NatsProtocol.OkBytes);
break;
case CommandType.Pong:
@@ -304,10 +310,14 @@ public sealed class NatsClient : IDisposable
case CommandType.Sub:
ProcessSub(cmd);
if (ClientOpts?.Verbose == true)
WriteProtocol(NatsProtocol.OkBytes);
break;
case CommandType.Unsub:
ProcessUnsub(cmd);
if (ClientOpts?.Verbose == true)
WriteProtocol(NatsProtocol.OkBytes);
break;
case CommandType.Pub: