Documentation ¶
Index ¶
- Constants
- Variables
- type Gateway
- func (c *Gateway) Close() error
- func (c *Gateway) HandleOP(op *wsutil.OP) error
- func (c *Gateway) Heartbeat() error
- func (c *Gateway) Identify() error
- func (c *Gateway) Open() error
- func (c *Gateway) Ready() ReadyEvent
- func (c *Gateway) Reconnect() error
- func (c *Gateway) Resume() error
- func (c *Gateway) SelectProtocol(data SelectProtocol) error
- func (c *Gateway) Send(code OPCode, v interface{}) error
- func (c *Gateway) SessionDescription(sp SelectProtocol) (*SessionDescriptionEvent, error)
- func (c *Gateway) Speaking(flag SpeakingFlag) error
- type Heartbeat
- type HeartbeatACKEvent
- type HelloEvent
- type IdentifyData
- type OPCode
- type ReadyEvent
- type ResumeData
- type ResumedEvent
- type SelectProtocol
- type SelectProtocolData
- type SessionDescriptionEvent
- type SpeakingData
- type SpeakingEvent
- type SpeakingFlag
- type State
Constants ¶
View Source
const (
// Version represents the current version of the Discord Gateway Gateway this package uses.
Version = "4"
)
Variables ¶
View Source
var ( // ErrMissingForIdentify is an error when we are missing information to identify. ErrMissingForIdentify = errors.New("missing GuildID, UserID, SessionID, or Token for identify") // ErrMissingForResume is an error when we are missing information to resume. ErrMissingForResume = errors.New("missing GuildID, SessionID, or Token for resuming") )
View Source
var ( ErrNoSessionID = errors.New("no sessionID was received") ErrNoEndpoint = errors.New("no endpoint was received") )
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct { Timeout time.Duration EventLoop *wsutil.PacemakerLoop // ErrorLog will be called when an error occurs (defaults to log.Println) ErrorLog func(err error) // AfterClose is called after each close. Error can be non-nil, as this is // called even when the Gateway is gracefully closed. It's used mainly for // reconnections or any type of connection interruptions. (defaults to noop) AfterClose func(err error) // contains filtered or unexported fields }
Gateway represents a Discord Gateway Gateway connection.
func (*Gateway) Heartbeat ¶
Heartbeat sends a Heartbeat operation (opcode 3) to the Gateway Gateway.
func (*Gateway) SelectProtocol ¶
func (c *Gateway) SelectProtocol(data SelectProtocol) error
SelectProtocol sends a Select Protocol operation (opcode 1) to the Gateway Gateway.
func (*Gateway) SessionDescription ¶
func (c *Gateway) SessionDescription(sp SelectProtocol) (*SessionDescriptionEvent, error)
func (*Gateway) Speaking ¶
func (c *Gateway) Speaking(flag SpeakingFlag) error
Speaking sends a Speaking operation (opcode 5) to the Gateway Gateway.
type HeartbeatACKEvent ¶
type HeartbeatACKEvent uint64
type HelloEvent ¶
type HelloEvent struct {
HeartbeatInterval discord.Milliseconds `json:"heartbeat_interval"`
}
type IdentifyData ¶
type OPCode ¶
OPCode represents a Discord Gateway Gateway operation code.
const ( IdentifyOP OPCode = 0 // send SelectProtocolOP OPCode = 1 // send ReadyOP OPCode = 2 // receive HeartbeatOP OPCode = 3 // send SessionDescriptionOP OPCode = 4 // receive SpeakingOP OPCode = 5 // send/receive HeartbeatAckOP OPCode = 6 // receive ResumeOP OPCode = 7 // send HelloOP OPCode = 8 // receive ResumedOP OPCode = 9 // receive )
type ReadyEvent ¶
type ReadyEvent struct { SSRC uint32 `json:"ssrc"` IP string `json:"ip"` Port int `json:"port"` Modes []string `json:"modes"` Experiments []string `json:"experiments"` }
func (ReadyEvent) Addr ¶
func (r ReadyEvent) Addr() string
type ResumeData ¶
type ResumedEvent ¶
type ResumedEvent struct{}
type SelectProtocol ¶
type SelectProtocol struct { Protocol string `json:"protocol"` Data SelectProtocolData `json:"data"` }
type SelectProtocolData ¶
type SessionDescriptionEvent ¶
type SpeakingData ¶
type SpeakingData struct { Speaking SpeakingFlag `json:"speaking"` Delay int `json:"delay"` SSRC uint32 `json:"ssrc"` }
OPCode 5 https://discordapp.com/developers/docs/topics/voice-connections#speaking-example-speaking-payload
type SpeakingFlag ¶
type SpeakingFlag uint64
https://discordapp.com/developers/docs/topics/voice-connections#speaking
const ( Microphone SpeakingFlag = 1 << iota Priority )
Click to show internal directories.
Click to hide internal directories.