BGE/Controller/WebSocketFrameCodec

Alias: BGE.Controller.WebSocketFrameCodec


Static Methods

computeAcceptKey(secWebSocketKey: string): string

static

Computes the Sec-WebSocket-Accept header value for a given Sec-WebSocket-Key request header (RFC 6455 section 4.2.2).

Parameters

  • secWebSocketKey (string)

Returns

  • string

encodeTextFrame(message: string): roByteArray

static

Note: encodeTextFrame/encodeFrame are not called by ControllerServer today - it never pushes a data frame to the browser (the handshake response is plain HTTP text). Kept, tested, and intentionally unused, ready for a server->client send path such as a keepalive ping/pong.

Parameters

  • message (string)

Returns

  • roByteArray

encodeFrame(opcode: integer, payload: roByteArray): roByteArray

static

Parameters

  • opcode (integer)
  • payload (roByteArray)

Returns

  • roByteArray

decodeFrames( buffer: roByteArray, bufferSize: integer, ): BGE.Controller.WebSocketFrameCodec.DecodeResult

static

Decodes as many complete frames as are present in the first bufferSize bytes of buffer. A trailing partial frame is left undecoded - the caller keeps bytes from bytesConsumed onward.

Parameters

  • buffer (roByteArray)
  • bufferSize (integer)

Returns

  • BGE.Controller.WebSocketFrameCodec.DecodeResult

decodeFrameAt( buffer: roByteArray, offset: integer, bufferSize: integer, ): BGE.Controller.WebSocketFrameCodec.DecodeFrameAtResult

static

Returns invalid if fewer than a full frame's worth of bytes are available yet (caller should wait for more data).

Parameters

  • buffer (roByteArray)
  • offset (integer)
  • bufferSize (integer)

Returns

  • BGE.Controller.WebSocketFrameCodec.DecodeFrameAtResult

bytesToShort(b1: integer, b2: integer): integer

static

Parameters

  • b1 (integer)
  • b2 (integer)

Returns

  • integer

bytesToLong(buffer: roByteArray, offset: integer): longinteger

static

Returns -1 if the MSB of the top byte is set - RFC 6455 section 5.2 requires the MSB of a 64-bit extended payload length to be 0; the caller (decodeFrameAt) treats -1 as "can't decode this frame."

Parameters

  • buffer (roByteArray)
  • offset (integer)

Returns

  • longinteger

shortToBytes(number: integer): roByteArray

static

Parameters

  • number (integer)

Returns

  • roByteArray

longToBytes(number: longinteger): roByteArray

static

Parameters

  • number (longinteger)

Returns

  • roByteArray

Enums

BGE.Controller.WebSocketFrameCodec.OpCode

enumstaticreadonly

Properties

  • continuation (default: 0)
  • text (default: 1)
  • binary (default: 2)
  • close (default: 8)
  • ping (default: 9)
  • pong (default: 10)

Other

ACCEPT_GUID

staticreadonly

Default: 258EAFA5-E914-47DA-95CA-C5AB0DC85B11

DecodedFrame

static

Properties

  • opcode (integer)
  • final (boolean)
  • payload (roByteArray)

DecodeResult

static

Properties

  • frames (dynamic)
  • bytesConsumed (integer) — bytes at the start of the input consumed by frames - anything after ' this is an incomplete trailing frame, keep it for the next call

DecodeFrameAtResult

static

decodeFrameAt()'s own internal result - a DecodedFrame plus where the next frame (if any) starts. Not exposed outside this file; decodeFrames() unpacks it back down to a plain DecodedFrame for its own DecodeResult.frames.

Properties

  • opcode (integer)
  • final (boolean)
  • payload (roByteArray)
  • nextOffset (integer)