Documentation ¶
Overview ¶
Package websocket SDK 需要实现的 websocket 定义。
Index ¶
- Variables
- func PanicHandler(e interface{}, session *dto.Session)
- func Register(ws WebSocket)
- func RegisterHandlers(handlers ...interface{}) dto.Intent
- func RegisterResumeSignal(signal syscall.Signal)
- type ATMessageEventHandler
- type AudioEventHandler
- type ChannelEventHandler
- type DirectMessageEventHandler
- type ErrorNotifyHandler
- type GuildEventHandler
- type GuildMemberEventHandler
- type MessageAuditEventHandler
- type MessageEventHandler
- type MessageReactionEventHandler
- type PlainEventHandler
- type ReadyHandler
- type WebSocket
Constants ¶
This section is empty.
Variables ¶
var DefaultHandlers struct { Ready ReadyHandler ErrorNotify ErrorNotifyHandler Plain PlainEventHandler Guild GuildEventHandler GuildMember GuildMemberEventHandler Channel ChannelEventHandler Message MessageEventHandler MessageReaction MessageReactionEventHandler ATMessage ATMessageEventHandler DirectMessage DirectMessageEventHandler Audio AudioEventHandler MessageAudit MessageAuditEventHandler }
DefaultHandlers 默认的 handler 结构,管理所有支持的 handler 类型
var PanicBufLen = 1024
PanicBufLen Panic 堆栈大小
Functions ¶
func PanicHandler ¶
PanicHandler 处理websocket场景的 panic ,打印堆栈
func RegisterHandlers ¶
RegisterHandlers 注册事件回调,并返回 intent 用于 websocket 的鉴权
func RegisterResumeSignal ¶
RegisterResumeSignal 注册用于通知 client 将连接进行 resume 的信号
Types ¶
type ATMessageEventHandler ¶
type ATMessageEventHandler func(event *dto.WSPayload, data *dto.WSATMessageData) error
ATMessageEventHandler at 机器人消息事件 handler
type AudioEventHandler ¶
type AudioEventHandler func(event *dto.WSPayload, data *dto.WSAudioData) error
AudioEventHandler 音频机器人事件 handler
type ChannelEventHandler ¶
type ChannelEventHandler func(event *dto.WSPayload, data *dto.WSChannelData) error
ChannelEventHandler 子频道事件 handler
type DirectMessageEventHandler ¶
type DirectMessageEventHandler func(event *dto.WSPayload, data *dto.WSDirectMessageData) error
DirectMessageEventHandler 私信消息事件 handler
type ErrorNotifyHandler ¶
type ErrorNotifyHandler func(err error)
ErrorNotifyHandler 当 ws 连接发生错误的时候,会回调,方便使用方监控相关错误 比如 reconnect invalidSession 等错误,错误可以转换为 bot.Err
type GuildEventHandler ¶
type GuildEventHandler func(event *dto.WSPayload, data *dto.WSGuildData) error
GuildEventHandler 频道事件handler
type GuildMemberEventHandler ¶
type GuildMemberEventHandler func(event *dto.WSPayload, data *dto.WSGuildMemberData) error
GuildMemberEventHandler 频道成员事件 handler
type MessageAuditEventHandler ¶
type MessageAuditEventHandler func(event *dto.WSPayload, data *dto.WSMessageAuditData) error
MessageAuditEventHandler 消息审核事件 handler
type MessageEventHandler ¶
type MessageEventHandler func(event *dto.WSPayload, data *dto.WSMessageData) error
MessageEventHandler 消息事件 handler
type MessageReactionEventHandler ¶
type MessageReactionEventHandler func(event *dto.WSPayload, data *dto.WSMessageReactionData) error
MessageReactionEventHandler 表情表态事件 handler
type PlainEventHandler ¶
PlainEventHandler 透传handler
type ReadyHandler ¶
type ReadyHandler func(event *dto.WSPayload, data *dto.WSReadyData)
ReadyHandler 可以处理 ws 的 ready 事件
type WebSocket ¶
type WebSocket interface { // New 创建一个新的ws实例,需要传递 session 对象 New(session dto.Session) WebSocket // Connect 连接到 wss 地址 Connect() error // Identify 鉴权连接 Identify() error // Session 拉取 session 信息,包括 token,shard,seq 等 Session() *dto.Session // Resume 重连 Resume() error // Listening 监听websocket事件 Listening() error // Write 发送数据 Write(message *dto.WSPayload) error // Close 关闭连接 Close() }
WebSocket 需要实现的接口