Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebSocketFrame

A WebSocket frame that represents either text or binary data.

A WebSocket message is composed of one or more WebSocket frames.

If there is a just a single frame in the message then a single text or binary frame should be created with final = true.

If there are more than one frames in the message, then the first frame should be a text or binary frame with final = false, followed by one or more continuation frames. The last continuation frame should have final = true.

Hierarchy

  • WebSocketFrame

Index

Methods

binaryData

  • Returns Buffer

closeReason

  • closeReason(): string
  • Returns string

closeStatusCode

  • closeStatusCode(): number
  • Returns number

isBinary

  • isBinary(): boolean
  • Returns boolean

isClose

  • isClose(): boolean
  • Returns boolean

isContinuation

  • isContinuation(): boolean
  • Returns boolean

isFinal

  • isFinal(): boolean
  • Returns boolean

isPing

  • isPing(): boolean
  • Returns boolean

isText

  • isText(): boolean
  • Returns boolean

textData

  • textData(): string
  • Returns string

type

  • Returns WebSocketFrameType

Static binaryFrame

  • Create a binary WebSocket frame.

    Parameters

    • data: Buffer
    • isFinal: boolean

    Returns WebSocketFrame

Static continuationFrame

  • Create a continuation frame

    Parameters

    • data: Buffer
    • isFinal: boolean

    Returns WebSocketFrame

Static pingFrame

  • Create a ping WebSocket frame. Will be a final frame. There is no option for non final ping frames.

    Parameters

    Returns WebSocketFrame

Static pongFrame

  • Create a pong WebSocket frame. Will be a final frame. There is no option for non final pong frames.

    Parameters

    Returns WebSocketFrame

Static textFrame

  • Create a text WebSocket frame.

    Parameters

    • str: string
    • isFinal: boolean

    Returns WebSocketFrame

Generated using TypeDoc