UNPKG

@stomp/stompjs

Version:

STOMP client for Javascript and Typescript

91 lines (90 loc) • 2.47 kB
import type { IFrame } from './i-frame.js'; import { StompHeaders } from './stomp-headers.js'; import { IRawFrameType } from './types.js'; /** * Frame class represents a STOMP frame. * * @internal */ export declare class FrameImpl implements IFrame { /** * STOMP Command */ command: string; /** * Headers, key value pairs. */ headers: StompHeaders; /** * Is this frame binary (based on whether body/binaryBody was passed when creating this frame). */ isBinaryBody: boolean; /** * body of the frame */ get body(): string; private _body; /** * body as Uint8Array */ get binaryBody(): Uint8Array; private _binaryBody; private escapeHeaderValues; private skipContentLengthHeader; /** * Frame constructor. `command`, `headers` and `body` are available as properties. * * @internal */ constructor(params: { command: string; headers?: StompHeaders | undefined; body?: string | undefined; binaryBody?: Uint8Array | undefined; escapeHeaderValues?: boolean | undefined; skipContentLengthHeader?: boolean | undefined; }); /** * deserialize a STOMP Frame from raw data. * * @internal */ static fromRawFrame(rawFrame: IRawFrameType, escapeHeaderValues: boolean): FrameImpl; /** * @internal */ toString(): string; /** * serialize this Frame in a format suitable to be passed to WebSocket. * If the body is string the output will be string. * If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer. * * @internal */ serialize(): string | ArrayBuffer; private serializeCmdAndHeaders; private isBodyEmpty; private bodyLength; private static toUnit8Array; /** * Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker. * * @internal */ static marshall(params: { command: string; headers?: StompHeaders | undefined; body?: string | undefined; binaryBody?: Uint8Array | undefined; escapeHeaderValues?: boolean | undefined; skipContentLengthHeader?: boolean | undefined; }): string | ArrayBuffer; /** * Escape header values */ private static hdrValueEscape; /** * UnEscape header values */ private static hdrValueUnEscape; }