ZlibStreamDecoder
Defined in: packages/ws/src/decoder.ts:65
Decodes Discord’s zlib-stream transport compression.
Discord sends one zlib stream whose logical payloads are separated by the
Z_SYNC_FLUSH marker 00 00 FF FF. A payload may span several WebSocket
messages, so output is produced only when that marker arrives: a partial
payload is retained rather than guessed at.
The inflater carries state across frames, so push calls must not
interleave. WebSocketTransport serialises them by construction.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ZlibStreamDecoder(
create?,maxFrameBytes?):ZlibStreamDecoder
Defined in: packages/ws/src/decoder.ts:88
Parameters
Section titled “Parameters”create?
Section titled “create?”() => Inflate
Inflater factory; injected in tests.
maxFrameBytes?
Section titled “maxFrameBytes?”number = ...
Largest inflated frame accepted (default 64 MiB); past it the stream fails instead of growing until memory runs out.
Returns
Section titled “Returns”ZlibStreamDecoder
Methods
Section titled “Methods”push()
Section titled “push()”push(
data):string[] |Promise<string[]>
Defined in: packages/ws/src/decoder.ts:103
A text frame on a compressed connection is already a complete frame, so
it is returned synchronously and never touches the inflater. Discord
sends everything binary under zlib-stream; tolerating a string costs
nothing, and treating one as a decode failure — or delaying it by a
microtask — would both change observable behaviour.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”string[] | Promise<string[]>
Implementation of
Section titled “Implementation of”reset()
Section titled “reset()”reset():
void
Defined in: packages/ws/src/decoder.ts:144
Discards buffered state. Call when a connection is replaced.
Returns
Section titled “Returns”void