DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
nats.h File Reference

NATS client protocol codec (DETWS_ENABLE_NATS) - zero-heap builder + parser for the text-based NATS pub/sub protocol, so a device can be a NATS client over the shipped outbound client transport. More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

NATS client protocol codec (DETWS_ENABLE_NATS) - zero-heap builder + parser for the text-based NATS pub/sub protocol, so a device can be a NATS client over the shipped outbound client transport.

NATS is a small, line-oriented protocol; every control line ends with CRLF and fields are space-separated:

CONNECT {json} // client -> server
PUB <subject> [reply-to] <#bytes>\r\n<payload> // client -> server
SUB <subject> [queue] <sid> // client -> server
UNSUB <sid> [max] // client -> server
MSG <subject> <sid> [reply-to] <#bytes>\r\n<payload> // server -> client
PING / PONG / +OK / -ERR <msg> / INFO {json}

Only PUB and MSG carry a payload (the byte count precedes a CRLF, then that many payload octets, then a trailing CRLF).

The builders write a control line (plus payload) into a caller buffer; the parser decodes one inbound message at the buffer head and reports the bytes consumed. Line formats per the NATS client protocol reference.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file nats.h.