Documentation
¶
Index ¶
- Constants
- func Run()
- type DanmuInfo
- type EventHandler
- func (e *EventHandler) Connect(addr string)
- func (e *EventHandler) OnClose(socket *gws.Conn, err error)
- func (e *EventHandler) OnMessage(socket *gws.Conn, message *gws.Message)
- func (e *EventHandler) OnOpen(socket *gws.Conn)
- func (e *EventHandler) OnPing(socket *gws.Conn, payload []byte)
- func (e *EventHandler) OnPong(socket *gws.Conn, payload []byte)
- type FixedLengthHeader
- type Message
Constants ¶
View Source
const ( CMD_DANMU_MSG = "DANMU_MSG" CMD_LIKE_INFO_V3_CLICK = "LIKE_INFO_V3_CLICK" CMD_LIKE_INFO_V3_UPDATE = "LIKE_INFO_V3_UPDATE" CMD_ROOM_REAL_TIME_MESSAGE_UPDATE = "ROOM_REAL_TIME_MESSAGE_UPDATE" CMD_SEND_GIFT = "SEND_GIFT" CMD_WATCHED_CHANGE = "WATCHED_CHANGE" )
View Source
const ( OP_HEARTBEAT = 2 //客户端发送的心跳包(30秒发送一次) OP_HEARTBEAT_REPLY = 3 //服务器收到心跳包的回复 OP_SEND_SMS_REPLY = 5 //服务器推送的弹幕消息包 OP_AUTH = 7 //客户端发送的鉴权包(客户端发送的第一个包) OP_AUTH_REPLY = 8 //服务器收到鉴权包后的回复 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DanmuInfo ¶
type DanmuInfo struct {
Code int `json:"code"`
Message string `json:"message"`
Ttl int `json:"ttl"`
Data struct {
Group string `json:"group"`
BusinessId int `json:"business_id"`
RefreshRowFactor float64 `json:"refresh_row_factor"`
RefreshRate int `json:"refresh_rate"`
MaxDelay int `json:"max_delay"`
Token string `json:"token"`
HostList []struct {
Host string `json:"host"`
Port int `json:"port"`
WssPort int `json:"wss_port"`
WsPort int `json:"ws_port"`
} `json:"host_list"`
} `json:"data"`
}
func GetDanmuInfo ¶
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
func NewEventHandler ¶
func NewEventHandler(roomid, uid int, buvid, cookie, token string) *EventHandler
func (*EventHandler) Connect ¶
func (e *EventHandler) Connect(addr string)
func (*EventHandler) OnMessage ¶
func (e *EventHandler) OnMessage(socket *gws.Conn, message *gws.Message)
func (*EventHandler) OnOpen ¶
func (e *EventHandler) OnOpen(socket *gws.Conn)
type FixedLengthHeader ¶
type FixedLengthHeader struct {
PacketLength uint32 //整个Packet的长度,包含Header
HeaderLength uint16 //Header的长度,固定为16
Version uint16 //压缩 2 zlib, 3 brotli
Operation uint32 //消息的类型
SequenceID uint32 //保留字段
}
FixedLengthHeader https://open-live.bilibili.com/document/657d8e34-f926-a133-16c0-300c1afc6e6b
type Message ¶
type Message struct {
Header FixedLengthHeader //所有字段 大端 对齐
Body []byte //消息体,客户端解析Body之前请先解析Version字段
}
Click to show internal directories.
Click to hide internal directories.