You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.4 KiB
Go
84 lines
2.4 KiB
Go
package bilibili
|
|
|
|
import "encoding/json"
|
|
|
|
// ws-ops
|
|
const (
|
|
WsOpHeartbeat = 2 // 心跳
|
|
WsOpHeartbeatReply = 3 // 心跳回应
|
|
WsOpMessage = 5 // 弹幕消息等
|
|
WsOpEnterRoomOrAuth = 7 // 请求进入房间
|
|
WsOpEnterRoomOrAuthReply = 8 // 进房回应
|
|
)
|
|
|
|
// version protocol
|
|
const (
|
|
WsVerPlain = 0
|
|
WsVerInt = 1
|
|
WsVerZlib = 2
|
|
WsVerBrotli = 3
|
|
)
|
|
|
|
type RoomInfo struct {
|
|
RoomId int64 `json:"room_id"` // 房间号(这个才能连接ws)
|
|
ShortId int64 `json:"short_id"` // 短房间号
|
|
Uid int `json:"uid"` // 主播UID
|
|
IsHidden bool `json:"is_hidden"` // 是否隐藏?
|
|
IsLocked bool `json:"is_locked"` // 是否被封
|
|
IsPortrait bool `json:"is_portrait"` // 是否竖屏
|
|
LiveStatus int `json:"live_status"` // 1开播 0可能是未开播
|
|
HiddenTill int64 `json:"hidden_till"` // 隐藏时限 timestamp
|
|
LockTill int64 `json:"lock_till"` // 解禁时间 timestamp
|
|
Encrypted bool `json:"encrypted"` // 是否加密?
|
|
PwdVerified bool `json:"pwd_verified"` // 密码是否验证?
|
|
LiveTime int64 `json:"live_time"` // 开播时间
|
|
RoomShield int `json:"room_shield"` //
|
|
IsSp int `json:"is_sp"` //
|
|
SpecialType int `json:"special_type"` //
|
|
}
|
|
|
|
// WsEntry bilibili websocket 结构 均为大端序 BigEndian
|
|
type WsEntry struct {
|
|
protoVer uint16
|
|
operation uint32
|
|
sequenceId uint32
|
|
data []byte
|
|
}
|
|
|
|
// JoinRoomReq 加入房间消息
|
|
type JoinRoomReq struct {
|
|
ClientVer string `json:"clientver,omitempty"` //key可不存在
|
|
Platform string `json:"platform,default=web"`
|
|
ProtoVer int `json:"protover,default=2"`
|
|
RoomId int64 `json:"roomid"` // 必填
|
|
Uid int64 `json:"uid"`
|
|
Type int `json:"type,default=2"`
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
// BaseResp 基础API返回
|
|
type BaseResp struct {
|
|
Code int64 `json:"code"`
|
|
Message string `json:"message"`
|
|
RequestId string `json:"request_id"`
|
|
Data json.RawMessage `json:"data"`
|
|
}
|
|
|
|
type WebsocketInfoReq struct {
|
|
RoomId int64 `json:"room_id"`
|
|
}
|
|
|
|
// WebsocketInfoResp 官方websocket信息回复
|
|
type WebsocketInfoResp struct {
|
|
Ip []string `json:"ip"`
|
|
AuthBody string `json:"auth_body"`
|
|
Host []string `json:"host"`
|
|
TcpPort []int64 `json:"tcp_port"`
|
|
WsPort []int64 `json:"ws_port"`
|
|
WssPort []int64 `json:"wss_port"`
|
|
}
|
|
|
|
type CMD struct {
|
|
CMD string `json:"cmd"`
|
|
}
|