Remedy.Gateway.WSState (Remedy v0.6.0) View Source

Contains all the information required to maintain the gateway WSState connection to Discord.

This is provided to allow the user to enact custom logic on the gateway events as they are received from the consumer. It should be noted that the websocket state consumed with an event is a 'snapshot' of the state at the time that event was received, and does not relate to the current state of the websocket.

Link to this section Summary

Functions

Gets the latency of the shard connection from a Remedy.Struct.WSState.t() struct.

Link to this section Types

Specs

conn() :: pid()

Specs

gateway() :: String.t()

Specs

gun_conn() :: pid()

Specs

gun_data_stream() :: Stream.t()

Specs

heartbeat_ack() :: boolean()

Specs

heartbeat_interval() :: integer()

Specs

heartbeat_timer() :: integer()

Specs

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

Specs

last_heartbeat_send() :: DateTime.t() | nil
Link to this type

payload_dispatch_event()

View Source

Specs

payload_dispatch_event() :: atom()

Specs

payload_op_code() :: integer()

Specs

payload_op_event() :: atom()

Specs

payload_sequence() :: integer()

Specs

session_id() :: String.t() | nil

Specs

shard() :: integer()

Specs

shard_pid() :: pid()

Specs

t() :: %Remedy.Gateway.WSState{
  conn: conn(),
  gateway: gateway(),
  gun_conn: gun_conn(),
  gun_data_stream: gun_data_stream(),
  heartbeat_ack: heartbeat_ack(),
  heartbeat_interval: heartbeat_interval(),
  heartbeat_timer: heartbeat_timer(),
  last_heartbeat_ack: last_heartbeat_ack(),
  last_heartbeat_send: last_heartbeat_send(),
  payload_dispatch_event: payload_dispatch_event(),
  payload_op_code: payload_op_code(),
  payload_op_event: payload_op_event(),
  payload_sequence: payload_sequence(),
  session_id: session_id(),
  shard: shard(),
  shard_pid: term(),
  token: token(),
  v: term(),
  zlib_context: zlib_context()
}

Specs

token() :: String.t()

Specs

zlib_context() :: term()

Link to this section Functions

Link to this function

get_shard_latency(state)

View Source

Gets the latency of the shard connection from a Remedy.Struct.WSState.t() struct.

Returns the latency in milliseconds as an integer, returning nil if unknown.