Documentation ¶
Index ¶
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" // 点赞 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" // 点赞 )
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 ¶
AutomaticParsingMessageCommand 自动解析消息命令 如果是已知的命令,data 会被解析成对应的结构体,否则 data 会被解析成 map[string]interface{}
Types ¶
type CmdAuthData ¶
type CmdAuthData struct {
Code int64 `json:"code,omitempty"`
}
CmdAuthData 鉴权数据
func (CmdAuthData) Success ¶
func (arp CmdAuthData) Success() bool
type CmdDanmuData ¶
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 ¶
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"` 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 CmdLikeData ¶
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"` 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 CmdSendGiftData ¶
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"` 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 ¶
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 ¶
type CmdSuperChatDelData struct { RoomID int `json:"room_id"` MessageIds []int `json:"message_ids"` MsgID string `json:"msg_id"` }
CmdSuperChatDelData SC删除数据
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.