crux_gateway v0.1.3 Crux.Gateway.Command View Source
Builds Gateway Commands.
Note: Only the sent ones can be found here.
A list of available op codes:
| OP Code | Name | |
|---|---|---|
| 0 | dispatch | received only |
| 1 | heartbeat | two way |
| 2 | identify | sent only |
| 3 | status_update | sent only |
| 4 | voice_state_update | sent only |
| 5 | voice_guild_ping | sent only |
| 6 | resume | sent only |
| 7 | reconnect | received only |
| 8 | request_guild_members | sent only |
| 9 | invalid_session | received only |
| 10 | hello | received only |
| 11 | heartbeat_ack | received only |
Link to this section Summary
Types
Used to set an activity via status_update/2
Encoded command ready to be sent to the gateway via Crux.Gateway.Connection.send_command/2
Functions
Builds a Heartbeat command
Builds an Identify command
Builds a Request Guild Members command
Builds a Resume command
Builds a Status Update command
Link to this section Types
activity() :: %{
:name => String.t(),
:type => non_neg_integer(),
optional(:url) => String.t()
}
Used to set an activity via status_update/2.
:type must be a valid Activity Type
Note that streaming requires a twitch url pointing to a possible channel!
Encoded command ready to be sent to the gateway via Crux.Gateway.Connection.send_command/2.
If you want to build custom commands,
pass :erlang.term_to_binary/1 a map with the keys op and d,
and wrap it in a tuple with :binary as first element.
Link to this section Functions
heartbeat(sequence :: integer()) :: gateway_command()
Builds a Heartbeat command.
Used to signalize the server that the client is still alive and able to receive messages.
identify(
data :: %{
shard_id: non_neg_integer(),
shard_count: non_neg_integer(),
token: String.t()
}
) :: gateway_command()
Builds an Identify command.
Used to identify the gateway connection and “log in”.
request_guild_members( guild_id :: pos_integer(), opts :: [query: String.t(), limit: pos_integer()] ) :: gateway_command()
Builds a Request Guild Members command.
Used to request guild member for a specific guild.
Note: This must be sent to the connection handling the guild, not just any connection.
The gateway will respond with :GUILD_MEMBER_CHUNK (a) packet(s).
resume(
data :: %{seq: non_neg_integer(), token: String.t(), session: String.t()}
) :: gateway_command()
Builds a Resume command.
Used to resume into a session which was unexpectly disconnected and may be resumable.
status_update(status :: String.t(), game :: activity()) :: gateway_command()
Builds a Status Update command.
Used to update the status of the client, including activity.
voice_state_update( guild_id :: pos_integer(), channel_id :: pos_integer() | nil, states :: [self_mute: boolean(), self_deaf: boolean()] ) :: gateway_command()
Builds a Voice State Update command.
Used to join, switch between, and leave voice channels.