Documentation
¶
Overview ¶
Package dispatcher handles opcode dispatching
Index ¶
- func ETFPayloadToMessage(ctx context.Context, ep ETFPayload) (wsapi.WSMessage, error)
- type DispatchHandlerFunc
- type Dispatcher
- func (c *Dispatcher) AddHandler(event string, handler DispatchHandlerFunc)
- func (c *Dispatcher) ConnectToBot(b *bot.DiscordBot)
- func (c *Dispatcher) GenerateHeartbeat(ctx context.Context, seqNum int) (wsapi.WSMessage, error)
- func (c *Dispatcher) HandleRequest(req wsapi.WSMessage, resp chan<- wsapi.WSMessage) snowflake.Snowflake
- func (c *Dispatcher) SetDebug(val bool)
- type ETFPayload
- type Logger
- type Payload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ETFPayloadToMessage ¶
ETFPayloadToMessage converts a specialized etf payload to a websocket message
Types ¶
type DispatchHandlerFunc ¶
type DispatchHandlerFunc = func(Payload, wsapi.WSMessage, chan<- wsapi.WSMessage) snowflake.Snowflake
DispatchHandlerFunc is the api that a bot expects a handler function to have
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is the op-code dispatcher
func NewDispatcher ¶
func NewDispatcher(deps dependencies) *Dispatcher
NewDispatcher creates a new Dispatcher object with default state and session management handlers installed
func (*Dispatcher) AddHandler ¶
func (c *Dispatcher) AddHandler(event string, handler DispatchHandlerFunc)
AddHandler adds a new event handler to the dispatch table
func (*Dispatcher) ConnectToBot ¶
func (c *Dispatcher) ConnectToBot(b *bot.DiscordBot)
ConnectToBot attaches this dispatcher to a bot instance
func (*Dispatcher) GenerateHeartbeat ¶
GenerateHeartbeat prepares a heartbeat message to be sent
func (*Dispatcher) HandleRequest ¶
func (c *Dispatcher) HandleRequest(req wsapi.WSMessage, resp chan<- wsapi.WSMessage) snowflake.Snowflake
HandleRequest dispatches a message and queues a response, if there is one
func (*Dispatcher) SetDebug ¶
func (c *Dispatcher) SetDebug(val bool)
SetDebug turns on/off debug mode
type ETFPayload ¶
ETFPayload is the interface that a specialized etf api payload conforms to