[]previous and next page

encodeFrame

Encodes one frame the server sends: a single final frame, unmasked, with the shortest length encoding.

Encodes one frame the server sends: a single final frame, unmasked, with the shortest length encoding. Text payloads are the UTF-8 bytes of the string; the caller passes bytes.

Import#

ts
import { encodeFrame } from "@shadow-js/dusk/server";

Signature#

ts
function encodeFrame(kind: OutgoingKind, payload: Uint8Array): Uint8Array

Parameters#

Name Description
kind The frame kind.
payload The payload (at most 125 bytes for ping, pong and close).

Returns#

The frame bytes.

Throws#

  • RangeError for a control frame with a payload over 125 bytes.