Documentation ¶
Index ¶
Constants ¶
const ( // Discord normal SessionNoLongerValid websocket.StatusCode = 4006 SessionTimeout websocket.StatusCode = 4009 Disconnected websocket.StatusCode = 4014 ServerCrashed websocket.StatusCode = 4015 // Discord abnormal UnknownOPCode websocket.StatusCode = 4001 FailedToDecodePayload websocket.StatusCode = 4002 NotAuthenticated websocket.StatusCode = 4003 AuthenticationFailed websocket.StatusCode = 4004 AlreadyAuthenticated websocket.StatusCode = 4005 ServerNotFound websocket.StatusCode = 4011 UnknownProtocol websocket.StatusCode = 4012 UnknownEncryption websocket.StatusCode = 4016 BfcordVoiceReconnect websocket.StatusCode = 4969 )
Variables ¶
var ( GatewayMissingValuesError = errors.New("some of the required values required to start connection are missing") ConnectionClosedError = errors.New("connection is closed") UDPHolepunchFailed = errors.New("failed to perform UDP holepunch in 10 tries") NotConnected = errors.New("session is not yet connected, or is reconnecting") )
Functions ¶
This section is empty.
Types ¶
type ConnectOptions ¶
type ConnectOptions struct { VoiceState *gateway.VoiceStateUpdateEvent VoiceServer *gateway.VoiceServerUpdateEvent ChannelID snowflake.ID GuildID snowflake.ID Debug bool OnClose func() }
type IdentifyPayload ¶
type Payload ¶
type Payload struct { Data json.RawMessage `json:"d"` Op OPCode `json:"op"` }
type ReadyPayload ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(ctx context.Context, opts ConnectOptions) (*Session, error)
NewSession function creates new session and issues first connection. Blocks until connection is finished (or until timeout occurs)
func (*Session) Destroy ¶
func (s *Session) Destroy()
Destroy method disconnects session from discord. Using SendOpusFrame after destroying will throw errors.
func (*Session) SendOpusFrame ¶
SendOpusFrame method writes raw audio frame to discord.
Frame MUST be 20ms in length. We may allow changing the value later if needed.
This method should not be used concurrently, as it will cause audio overlapping.
Will throw ConnectionClosedError if connection is closed permanently.
func (*Session) SendSpeaking ¶
func (s *Session) SendSpeaking(flags SpeakingFlag) error
SendSpeaking method sends speaking flags to discord.
It's automatically invoked during (re)connection.
Will throw an error if connection is not yet finished.
type SpeakingFlag ¶
type SpeakingFlag uint64
const ( NotSpeaking SpeakingFlag = 0 Microphone SpeakingFlag = 1 << iota Priority )