Pure codec for Discord Gateway v10 JSON frames.
Stateless: encodes the three client payloads the socket sends
(heartbeat, identify, resume) and classifies inbound frames into tagged
tuples. All connection state (sequence numbers, session ids, timers)
lives in Raxol.Gateway.Adapter.Discord.GatewaySocket.
Dispatch frames (op 0) are returned whole and string-keyed, exactly as
decoded, so the socket can hand them to its :on_event sink unmodified.
Summary
Functions
Classify one inbound text frame.
The default intent bitfield: GUILDS, GUILD_MESSAGES, DIRECT_MESSAGES, and MESSAGE_CONTENT.
Encode a heartbeat (op 1) carrying the last seen sequence (or nil).
Encode an identify (op 2) with token and intents.
Encode a resume (op 6) for an interrupted session.
Types
@type decoded() :: {:dispatch, map()} | {:hello, pos_integer()} | :heartbeat_request | :heartbeat_ack | :reconnect | {:invalid_session, resumable? :: boolean()} | {:unknown, term()} | {:error, term()}
Functions
Classify one inbound text frame.
@spec default_intents() :: pos_integer()
The default intent bitfield: GUILDS, GUILD_MESSAGES, DIRECT_MESSAGES, and MESSAGE_CONTENT.
MESSAGE_CONTENT is privileged: it must also be enabled for the bot in the Discord developer portal, or guild message content arrives empty.
Encode a heartbeat (op 1) carrying the last seen sequence (or nil).
@spec encode_identify(String.t(), pos_integer()) :: String.t()
Encode an identify (op 2) with token and intents.
Encode a resume (op 6) for an interrupted session.