Documentation
¶
Index ¶
- Constants
- Variables
- func AutomaticParsingMessageCommand(payload []byte) (string, interface{}, error)
- type Cmd
- type CmdAuthData
- type CmdDanmuData
- type CmdGuardData
- type CmdInteractWordData
- type CmdInteractionEndData
- type CmdLikeData
- type CmdLiveEndData
- type CmdLiveRoomEnterData
- type CmdLiveStartData
- type CmdRoomBlockMsgData
- type CmdRoomChangeData
- type CmdSendGiftData
- type CmdSuperChatData
- type CmdSuperChatDelData
- type CmdWarningData
- type Header
- type Message
Constants ¶
View Source
const ( CmdLiveOpenPlatformDanmu = "LIVE_OPEN_PLATFORM_DM" // 弹幕 CmdLiveOpenPlatformSendGift = "LIVE_OPEN_PLATFORM_SEND_GIFT" // 礼物 CmdLiveOpenPlatformSuperChat = "LIVE_OPEN_PLATFORM_SUPER_CHAT" // SC CmdLiveOpenPlatformSuperChatDel = "LIVE_OPEN_PLATFORM_SUPER_CHAT_DEL" // SC删除 CmdLiveOpenPlatformGuard = "LIVE_OPEN_PLATFORM_GUARD" // 付费大航海 CmdLiveOpenPlatformLike = "LIVE_OPEN_PLATFORM_LIKE" // 点赞 CmdLiveOpenPlatformRoomEnter = "LIVE_OPEN_PLATFORM_LIVE_ROOM_ENTER" // 进入房间 CmdLiveOpenPlatformLiveStart = "LIVE_OPEN_PLATFORM_LIVE_START" // 开始直播 CmdLiveOpenPlatformLiveEnd = "LIVE_OPEN_PLATFORM_LIVE_END" // 结束直播 CmdLiveRoomDanmu = "OPEN_LIVEROOM_DM" // 弹幕 CmdLiveRoomSendGift = "OPEN_LIVEROOM_SEND_GIFT" // 礼物 CmdLiveRoomSuperChat = "OPEN_LIVEROOM_SUPER_CHAT" // SC CmdLiveRoomSuperChatDel = "OPEN_LIVEROOM_SUPER_CHAT_DEL" // SC删除 CmdLiveRoomSuperGuard = "OPEN_LIVEROOM_GUARD" // 付费大航海 CmdLiveRoomLike = "OPEN_LIVEROOM_LIKE" // 点赞 CmdLiveRoomLiveRoomEnter = "OPEN_LIVEROOM_LIVE_ROOM_ENTER" // 进入房间 CmdLiveRoomLiveStart = "OPEN_LIVEROOM_LIVE_START" // 开始直播 CmdLiveRoomLiveEnd = "OPEN_LIVEROOM_LIVE_END" // 结束直播 CmdLiveRoomRoomChange = "OPEN_LIVEROOM_ROOM_CHANGE" // 直播间基础信息更新 CmdLiveRoomRoomBlockMsg = "OPEN_LIVEROOM_ROOM_BLOCK_MSG" // 用户禁言通知 CmdLiveRoomInteractWord = "OPEN_LIVEROOM_INTERACT_WORD" // 用户关注通知 CmdLiveRoomWarning = "OPEN_LIVEROOM_WARNING" // 直播间警告信息 )
View Source
const ( OperationHeartbeat = 2 // 心跳 OperationHeartbeatReply = 3 // 心跳回包 OperationMessage = 5 // 消息包 OperationUserAuthentication = 7 // 鉴权包 OperationUserAuthenticationReply = 8 // 鉴权回包 )
View Source
const ( PackageHeaderTotalLength = 16 PackageOffset = 0 HeaderOffset = 4 VersionOffset = 6 OperationOffset = 8 SequenceOffset = 12 BodyProtocolVersionNormal = 0 BodyProtocolVersionZlib = 2 HeaderDefaultVersion = 1 HeaderDefaultOperation = 1 HeaderDefaultSequence = 1 )
Variables ¶
View Source
var (
PackLengthError = stderr.New("pack length error")
)
Functions ¶
func AutomaticParsingMessageCommand ¶ added in v0.2.1
AutomaticParsingMessageCommand 自动解析消息命令 如果是已知的命令,data 会被解析成对应的结构体,否则 data 会被解析成 map[string]interface{}
Types ¶
type Cmd ¶ added in v0.2.1
type Cmd struct { Cmd string `json:"cmd"` Data interface{} `json:"data"` }
type CmdAuthData ¶ added in v0.2.1
type CmdAuthData struct {
Code int64 `json:"code,omitempty"`
}
CmdAuthData 鉴权数据
func (CmdAuthData) Success ¶ added in v0.2.1
func (arp CmdAuthData) Success() bool
type CmdDanmuData ¶ added in v0.2.1
type CmdDanmuData struct { RoomID int `json:"room_id"` OpenID string `json:"open_id"` Uid int `json:"uid"` Uname string `json:"uname"` Msg string `json:"msg"` MsgID string `json:"msg_id"` FansMedalLevel int `json:"fans_medal_level"` FansMedalName string `json:"fans_medal_name"` FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` GuardLevel int `json:"guard_level"` Timestamp int `json:"timestamp"` UFace string `json:"uface"` EmojiImgUrl string `json:"emoji_img_url"` DmType int `json:"dm_type"` }
CmdDanmuData 弹幕数据
type CmdGuardData ¶ added in v0.2.1
type CmdGuardData struct { UserInfo struct { OpenID string `json:"open_id"` Uid int `json:"uid"` Uname string `json:"uname"` Uface string `json:"uface"` } `json:"user_info"` GuardLevel int `json:"guard_level"` GuardNum int `json:"guard_num"` GuardUnit string `json:"guard_unit"` Price int `json:"price"` FansMedalLevel int `json:"fans_medal_level"` FansMedalName string `json:"fans_medal_name"` FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` Timestamp int `json:"timestamp"` RoomID int `json:"room_id"` MsgID string `json:"msg_id"` }
CmdGuardData 付费大航海数据
type CmdInteractWordData ¶ added in v0.2.4
type CmdInteractWordData struct { // 推送消息的唯一ID MsgID string `json:"msg_id"` // 用户唯一标识 OpenID string `json:"open_id"` // 发生的直播间 RoomID int64 `json:"room_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` // 用户昵称 Uname string `json:"uname"` }
CmdInteractWordData 用户关注通知数据
type CmdInteractionEndData ¶ added in v0.2.4
type CmdInteractionEndData struct { // 结束消息推送的conn_id ConnID string `json:"conn_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` }
CmdInteractionEndData 消息推送结束通知数据
type CmdLikeData ¶ added in v0.2.1
type CmdLikeData struct { Uname string `json:"uname"` OpenID string `json:"open_id"` Uid int `json:"uid"` Uface string `json:"uface"` Timestamp int `json:"timestamp"` LikeText string `json:"like_text"` LikeCount int `json:"like_count"` FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` FansMedalName string `json:"fans_medal_name"` FansMedalLevel int `json:"fans_medal_level"` MsgID string `json:"msg_id"` RoomID int `json:"room_id"` }
CmdLikeData 点赞数据
type CmdLiveEndData ¶ added in v0.2.3
type CmdLiveEndData struct { // 发生的直播间 RoomID int64 `json:"room_id"` // 用户唯一标识 OpenID string `json:"open_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` // 开播二级分区名称 AreaName string `json:"area_name"` // 开播时刻,直播间的标题 Title string `json:"title"` }
CmdLiveEndData 结束直播数据
type CmdLiveRoomEnterData ¶ added in v0.2.3
type CmdLiveRoomEnterData struct { // 发生的直播间 RoomID int64 `json:"room_id"` // 用户头像 Uface string `json:"uface"` // 用户昵称 Uname string `json:"uname"` // 用户唯一标识 OpenID string `json:"open_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` }
CmdLiveRoomEnterData 进入房间数据
type CmdLiveStartData ¶ added in v0.2.3
type CmdLiveStartData struct { // 发生的直播间 RoomID int64 `json:"room_id"` // 用户唯一标识 OpenID string `json:"open_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` // 开播二级分区名称 AreaName string `json:"area_name"` // 开播时刻,直播间的标题 Title string `json:"title"` }
CmdLiveStartData 开始直播数据
type CmdRoomBlockMsgData ¶ added in v0.2.4
type CmdRoomBlockMsgData struct { // 禁言结束时间戳(UTC+8,秒) BlockExpired int64 `json:"block_expired"` // 推送消息的唯一ID MsgID string `json:"msg_id"` // 用户唯一标识 OpenID string `json:"open_id"` // 发生的直播间 RoomID int64 `json:"room_id"` // 用户昵称 Uname string `json:"uname"` }
CmdRoomBlockMsgData 用户禁言通知数据
type CmdRoomChangeData ¶ added in v0.2.4
type CmdRoomChangeData struct { // 开播二级分区名称 AreaName string `json:"area_name"` // 推送消息的唯一ID MsgID string `json:"msg_id"` // 开播一级分区名称 ParentAreaName string `json:"parent_area_name"` // 发生的直播间 RoomID int64 `json:"room_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` // 直播间的标题 Title string `json:"title"` }
CmdRoomChangeData 直播间基础信息变化数据
type CmdSendGiftData ¶ added in v0.2.1
type CmdSendGiftData struct { RoomID int `json:"room_id"` OpenID string `json:"open_id"` Uid int `json:"uid"` Uname string `json:"uname"` Uface string `json:"uface"` GiftID int `json:"gift_id"` GiftName string `json:"gift_name"` GiftNum int `json:"gift_num"` Price int `json:"price"` RPrice int `json:"r_price"` Paid bool `json:"paid"` FansMedalLevel int `json:"fans_medal_level"` FansMedalName string `json:"fans_medal_name"` FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` GuardLevel int `json:"guard_level"` Timestamp int `json:"timestamp"` MsgID string `json:"msg_id"` AnchorInfo struct { OpenID string `json:"open_id"` Uid int `json:"uid"` Uname string `json:"uname"` Uface string `json:"uface"` } `json:"anchor_info"` GiftIcon string `json:"gift_icon"` ComboGift bool `json:"combo_gift"` ComboInfo struct { ComboBaseNum int `json:"combo_base_num"` ComboCount int `json:"combo_count"` ComboID string `json:"combo_id"` ComboTimeout int `json:"combo_timeout"` } `json:"combo_info"` }
CmdSendGiftData 礼物数据
type CmdSuperChatData ¶ added in v0.2.1
type CmdSuperChatData struct { RoomID int `json:"room_id"` OpenID string `json:"open_id"` Uid int `json:"uid"` Uname string `json:"uname"` Uface string `json:"uface"` MessageID int `json:"message_id"` Message string `json:"message"` MsgID string `json:"msg_id"` Rmb int `json:"rmb"` Timestamp int `json:"timestamp"` StartTime int `json:"start_time"` EndTime int `json:"end_time"` GuardLevel int `json:"guard_level"` FansMedalLevel int `json:"fans_medal_level"` FansMedalName string `json:"fans_medal_name"` FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` }
CmdSuperChatData SC数据
type CmdSuperChatDelData ¶ added in v0.2.1
type CmdSuperChatDelData struct { RoomID int `json:"room_id"` MessageIds []int `json:"message_ids"` MsgID string `json:"msg_id"` }
CmdSuperChatDelData SC删除数据
type CmdWarningData ¶ added in v0.2.4
type CmdWarningData struct { // 警告信息内容 Msg string `json:"msg"` // 推送消息的唯一ID MsgID string `json:"msg_id"` // 发生的直播间 RoomID int64 `json:"room_id"` // 发生的时间戳 Timestamp int64 `json:"timestamp"` }
CmdWarningData 直播间警告信息数据
type Header ¶
type Header struct { PackLength uint32 HeadLength uint16 Version uint16 Operation uint32 Sequence uint32 }
func PackHeader ¶
func UnpackHeader ¶
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func PackMessage ¶
func UnpackMessage ¶
UnpackMessage 解析直播间消息 被压缩的消息是一组 Message, 所以解析完成会返回 []Message 而非 Message
Click to show internal directories.
Click to hide internal directories.