glyph/network/gateway

This handles the logic for communicating with the Discord Gateway API. For more information: https://discord.com/developers/docs/topics/gateway

Types

pub type ActorState {
  ActorState(
    seq: Option(Int),
    heartbeat_in_ms: Int,
    self: process.Subject(Msg),
    resume_gateway_url: String,
    bot_id: discord.Snowflake,
    handlers: discord.EventHandler,
    received_hello: Bool,
  )
}

Constructors

  • ActorState(
      seq: Option(Int),
      heartbeat_in_ms: Int,
      self: process.Subject(Msg),
      resume_gateway_url: String,
      bot_id: discord.Snowflake,
      handlers: discord.EventHandler,
      received_hello: Bool,
    )
pub type GatewayError {
  JsonError(json.DecodeError)
  DynError(dynamic.DecodeError)
  DynErrors(dynamic.DecodeErrors)
}

Constructors

  • JsonError(json.DecodeError)
  • DynError(dynamic.DecodeError)
  • DynErrors(dynamic.DecodeErrors)
pub type Msg {
  Close
  Heartbeat
  Identify
  Resume
}

Constructors

  • Close
  • Heartbeat
  • Identify
  • Resume

Functions

pub fn handle_gateway_recv(
  msg: String,
  state: ActorState,
  conn: Connection,
) -> ActorState

This handles communicating with the gateway based on op codes: https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes

pub fn start_ws_loop(
  discord_token: String,
  intents: Int,
  url: String,
  event_handlers: EventHandler,
) -> a
Search Document