WebsockexNova.Gun.FrameHandlers.ControlFrameHandler (WebsockexNova v0.1.1)

View Source

Handler for WebSocket control frames (ping, pong, close).

Implements encoding, decoding, and validation specific to control frames.

Summary

Functions

Validates a WebSocket close code according to the protocol.

Validates that a control frame payload isn't too large.

Functions

validate_close_code(code)

Validates a WebSocket close code according to the protocol.

Parameters

  • code - The close code to validate

Returns

  • :ok - If the close code is valid
  • {:error, reason} - If the close code is invalid or reserved

validate_control_frame_size(data)

Validates that a control frame payload isn't too large.

WebSocket protocol limits control frame payloads to 125 bytes.

Parameters

  • data - The binary payload to check

Returns

  • :ok - If the payload size is valid
  • {:error, :control_frame_too_large} - If the payload is too large