Nostrum.Struct.WSState (nostrum v0.11.0-dev)

View Source

Struct representing the current WS state.

Summary

Types

Reference to the current compression context

PID of the :gun worker connected to the websocket

PID of the connection process

The consumer callback module. See Nostrum.Consumer.

Gateway URL

Whether or not the last hearbeat sent was ACK'd

Interval at which heartbeats are sent

The time the last heartbeat was acknowledged, will be nil if a heartbeat hasn't been ACK'd yet

The time the last heartbeat was sent, if a heartbeat hasn't been sent it will be the time the websocket process was started

Gateway URL to use for resuming.

The sequence number of the last event

The session id

The shard number

Stream reference for :gun

t()

The highest shard number for this bot.

The bot token that this shard is running with, wrapped in a function.

Types

compress_ctx()

@type compress_ctx() :: reference() | nil

Reference to the current compression context

conn()

@type conn() :: pid()

PID of the :gun worker connected to the websocket

conn_pid()

@type conn_pid() :: pid()

PID of the connection process

consumer()

(since 0.11.0)
@type consumer() :: module()

The consumer callback module. See Nostrum.Consumer.

gateway()

@type gateway() :: String.t()

Gateway URL

heartbeat_ack()

@type heartbeat_ack() :: boolean()

Whether or not the last hearbeat sent was ACK'd

heartbeat_interval()

@type heartbeat_interval() :: pos_integer() | nil

Interval at which heartbeats are sent

last_heartbeat_ack()

@type last_heartbeat_ack() :: DateTime.t() | nil

The time the last heartbeat was acknowledged, will be nil if a heartbeat hasn't been ACK'd yet

last_heartbeat_send()

@type last_heartbeat_send() :: DateTime.t()

The time the last heartbeat was sent, if a heartbeat hasn't been sent it will be the time the websocket process was started

resume_gateway()

(since 0.9.0)
@type resume_gateway() :: String.t() | nil

Gateway URL to use for resuming.

seq()

@type seq() :: integer() | nil

The sequence number of the last event

session()

@type session() :: integer() | nil

The session id

shard_num()

@type shard_num() :: non_neg_integer()

The shard number

stream()

(since 0.5.0)
@type stream() :: :gun.stream_ref()

Stream reference for :gun

t()

@type t() :: %Nostrum.Struct.WSState{
  compress_ctx: compress_ctx(),
  conn: conn(),
  conn_pid: conn_pid(),
  consumer: consumer(),
  gateway: gateway(),
  heartbeat_ack: heartbeat_ack(),
  heartbeat_interval: heartbeat_interval(),
  intents: Nostrum.Bot.intents(),
  last_heartbeat_ack: last_heartbeat_ack(),
  last_heartbeat_send: last_heartbeat_send(),
  resume_gateway: resume_gateway(),
  seq: seq(),
  session: session(),
  shard_num: shard_num(),
  stream: stream(),
  total_shards: total_shards(),
  wrapped_token: wrapped_token()
}

total_shards()

(since 0.8.0)
@type total_shards() :: non_neg_integer()

The highest shard number for this bot.

This may not be started locally, it is just used by nostrum to inform the gateway which events we are interested in.

wrapped_token()

(since 0.11.0)
@type wrapped_token() :: (-> String.t())

The bot token that this shard is running with, wrapped in a function.