2020-04-25 02:36:33 +00:00
|
|
|
package voicegateway
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
2021-06-02 02:53:19 +00:00
|
|
|
"github.com/diamondburned/arikawa/v3/discord"
|
2020-04-25 02:36:33 +00:00
|
|
|
)
|
2020-04-20 01:21:10 +00:00
|
|
|
|
|
|
|
// OPCode 2
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload
|
2020-04-20 01:21:10 +00:00
|
|
|
type ReadyEvent struct {
|
|
|
|
SSRC uint32 `json:"ssrc"`
|
|
|
|
IP string `json:"ip"`
|
|
|
|
Port int `json:"port"`
|
|
|
|
Modes []string `json:"modes"`
|
|
|
|
Experiments []string `json:"experiments"`
|
|
|
|
|
|
|
|
// From Discord's API Docs:
|
|
|
|
//
|
|
|
|
// `heartbeat_interval` here is an erroneous field and should be ignored.
|
|
|
|
// The correct `heartbeat_interval` value comes from the Hello payload.
|
|
|
|
|
|
|
|
// HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
|
|
|
|
}
|
|
|
|
|
2020-04-25 02:36:33 +00:00
|
|
|
func (r ReadyEvent) Addr() string {
|
|
|
|
return r.IP + ":" + strconv.Itoa(r.Port)
|
|
|
|
}
|
|
|
|
|
2020-04-20 01:21:10 +00:00
|
|
|
// OPCode 4
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-session-description-payload
|
2020-04-20 01:21:10 +00:00
|
|
|
type SessionDescriptionEvent struct {
|
|
|
|
Mode string `json:"mode"`
|
|
|
|
SecretKey [32]byte `json:"secret_key"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// OPCode 5
|
|
|
|
type SpeakingEvent SpeakingData
|
|
|
|
|
|
|
|
// OPCode 6
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/voice-connections#heartbeating-example-heartbeat-ack-payload
|
2020-04-20 01:21:10 +00:00
|
|
|
type HeartbeatACKEvent uint64
|
|
|
|
|
|
|
|
// OPCode 8
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/voice-connections#heartbeating-example-hello-payload-since-v3
|
2020-04-20 01:21:10 +00:00
|
|
|
type HelloEvent struct {
|
2020-04-25 02:36:33 +00:00
|
|
|
HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
|
2020-04-20 01:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// OPCode 9
|
2020-11-03 17:16:42 +00:00
|
|
|
// https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection-example-resumed-payload
|
2020-04-20 01:21:10 +00:00
|
|
|
type ResumedEvent struct{}
|
2020-11-15 19:45:47 +00:00
|
|
|
|
|
|
|
// OPCode 12
|
|
|
|
// (undocumented)
|
|
|
|
type ClientConnectEvent struct {
|
|
|
|
UserID discord.UserID `json:"user_id"`
|
|
|
|
AudioSSRC uint32 `json:"audio_ssrc"`
|
|
|
|
VideoSSRC uint32 `json:"video_ssrc"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// OPCode 13
|
|
|
|
// Undocumented, existence mentioned in below issue
|
|
|
|
// https://github.com/discord/discord-api-docs/issues/510
|
|
|
|
type ClientDisconnectEvent struct {
|
|
|
|
UserID discord.UserID `json:"user_id"`
|
|
|
|
}
|