Types
Framing = object recvMsg*: FramingRecvMsg sendMsg*: FramingSendMsg
- Source Edit
FramingRecvMsg = proc (transport: StreamTransport; limit: int): Future[seq[byte]] {. async: (...raises: [CancelledError, TransportError]), nimcall.}
- Source Edit
FramingSendMsg = proc (transport: StreamTransport; sendMsg: seq[byte]) {. async: (...raises: [CancelledError, TransportError]), nimcall.}
- Source Edit
Procs
proc httpHeader(T: type Framing): T:type {....raises: [], gcsafe.}
-
Framing using a HTTP-like Content-Length: <length>\r\n header followed by an empty line ("rn") followed by a the message itself.
This encoding is compatible with the default encoding used by StreamJsonRPC and https://www.npmjs.com/package/vscode-jsonrpc.
For a higher-performance option, use Framing.lengthHeaderBE32.
Source Edit proc init(T: type Framing; recvMsg: FramingRecvMsg; sendMsg: FramingSendMsg): T:type {. ...raises: [], gcsafe.}
- Source Edit
proc lengthHeaderBE32(T: type Framing): T:type {....raises: [], gcsafe.}
- Framing using a big-endian 32-bit length prefix. Source Edit
proc newLine(T: type Framing): T:type {....deprecated: "Prefer lengthHeaderBE32 or httpHeader in in new applications", raises: [], gcsafe.}
-
A framing that suffixes messages with "rn". This framing is supported only for historical purposes and may be removed in a future version.
The framing can only be used with payloads that do not contain newlines and message length is checked only after that many bytes have been transmitted.
Source Edit