Documentation
¶
Index ¶
- func DebugHandler(c *Context)
- func DefaultHandler(c *Context)
- type BiliLiveClient
- func (bili *BiliLiveClient) ConnectServer(roomID int) error
- func (bili *BiliLiveClient) GetRoomID() int
- func (bili *BiliLiveClient) RegHandleFunc(cmd CmdType, hfunc HandleFunc)
- func (bili *BiliLiveClient) Run()
- func (bili *BiliLiveClient) SendJoinChannel(channelID int) error
- func (bili *BiliLiveClient) Write(data []byte) error
- type CmdType
- type ConnType
- type Context
- func (c *Context) Abort()
- func (p *Context) GetDanmuInfo() *DanmuInfo
- func (p *Context) GetGiftInfo() *GiftInfo
- func (p *Context) GetNoticeMsg() *NoticeMsg
- func (p *Context) GetOnlineNumber() int
- func (p *Context) GetSuperChatMsg() *SuperChatMsg
- func (p *Context) GetWelcomeGuardInfo() *WelcomeGuardInfo
- func (p *Context) GetWelcomeInfo() *WelcomeInfo
- func (c *Context) IsAbort() bool
- type DanmuInfo
- type GiftInfo
- type HandleFunc
- type NoticeMsg
- type SuperChatMsg
- type WelcomeGuardInfo
- type WelcomeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BiliLiveClient ¶
type BiliLiveClient struct {
ChatPort int
ChatHost string
// contains filtered or unexported fields
}
func (*BiliLiveClient) ConnectServer ¶
func (bili *BiliLiveClient) ConnectServer(roomID int) error
ConnectServer define
func (*BiliLiveClient) GetRoomID ¶
func (bili *BiliLiveClient) GetRoomID() int
GetRoomID Get the current room ID
func (*BiliLiveClient) RegHandleFunc ¶
func (bili *BiliLiveClient) RegHandleFunc(cmd CmdType, hfunc HandleFunc)
func (*BiliLiveClient) SendJoinChannel ¶
func (bili *BiliLiveClient) SendJoinChannel(channelID int) error
SendJoinChannel define
func (*BiliLiveClient) Write ¶
func (bili *BiliLiveClient) Write(data []byte) error
type CmdType ¶
type CmdType string
const ( // CmdAll 订阅所有cmd事件时使用 CmdAll CmdType = "" // CmdLive 直播开始 CmdLive CmdType = "LIVE" // CmdPreparing 直播准备中 CmdPreparing CmdType = "PREPARING" // CmdDanmuMsg 弹幕消息 // {"cmd":"DANMU_MSG","info":[[0,1,25,16777215,1591004454028,-1464052061,0,"034722a0",0,0,0],"我改一下",[23624052,"星云之音喵",0,0,0,10000,1,""],[1,"谜酥","谜之声",5082,6406234,"",0],[12,0,6406234,"\u003e50000"],["",""],0,0,null,{"ts":1591004454,"},0,0,null,null,0]} CmdDanmuMsg CmdType = "DANMU_MSG" // CmdWelcomeGuard 管理进房 // {"cmd":"WELCOME_GUARD","data":{"uid":2721583,"username":"超高校级的无节操","gul":3,"mock_effect":0}} CmdWelcomeGuard CmdType = "WELCOME_GUARD" // CmdWelcome 群众进房 CmdWelcome CmdType = "WELCOME" // CmdSendGift 赠送礼物 CmdSendGift CmdType = "SEND_GIFT" // CmdNoticeMsg 系统消息通知 CmdNoticeMsg CmdType = "NOTICE_MSG" // CmdOnlineChange 在线人数变动,这不是一个标准cmd类型,仅为了统一handler接口而加入 CmdOnlineChange CmdType = "ONLINE_CHANGE" CmdSuperChatMsg CmdType = "SUPER_CHAT_MESSAGE" // 付费留言 )
type Context ¶
type Context struct {
Msg *simplejson.Json
RoomID int
Cmd CmdType
// contains filtered or unexported fields
}
Context 消息上下文环境,提供快捷提取消息数据的功能
func (*Context) GetDanmuInfo ¶
GetDanmuInfo 在Handler中调用,从simplejson.Json中提取弹幕信息
func (*Context) GetOnlineNumber ¶
GetOnlineNumber 在Handler中调用,从simplejson.Json中提取房间在线人气值
func (*Context) GetWelcomeGuardInfo ¶
func (p *Context) GetWelcomeGuardInfo() *WelcomeGuardInfo
GetWelcomeGuardInfo 在Handler中调用,从一个simplejson.Json中提取管理进房信息
func (*Context) GetWelcomeInfo ¶
func (p *Context) GetWelcomeInfo() *WelcomeInfo
GetWelcomeInfo 在Handler中调用,从一个simplejson.Json中提取普通人员进房信息
type DanmuInfo ¶
type DanmuInfo struct {
UID int `json:"uid"` //用户ID
Uname string `json:"uname"` //用户名称
Rank int `json:"rank"` //用户排名
Level int `json:"level"` //用户等级
Text string `json:"text"` //说的话
MedalLevel int `json:"medal_level"` //勋章等级
MedalName string `json:"medal_name"` //勋章名称
MedalAnchor string `json:"medal_anchor"` //勋章所属主播
}
DanmuInfo 弹幕信息
type GiftInfo ¶
type GiftInfo struct {
Action string `json:"action"`
AddFollow int `json:"addFollow"`
BeatID string `json:"beatId"`
BizSource string `json:"biz_source"`
Capsule struct {
Colorful struct {
Change int `json:"change"`
Coin int `json:"coin"`
Progress struct {
Max int `json:"max"`
Now int `json:"now"`
} `json:"progress"`
} `json:"colorful"`
Normal struct {
Change int `json:"change"`
Coin int `json:"coin"`
Progress struct {
Max int `json:"max"`
Now int `json:"now"`
} `json:"progress"`
} `json:"normal"`
} `json:"capsule"`
EventNum int `json:"eventNum"`
EventScore int `json:"eventScore"`
GiftID int `json:"giftId"`
GiftName string `json:"giftName"`
GiftType int `json:"giftType"`
CoinType string `json:"coin_type"` // 礼物类型 silver(银瓜子) gold(金瓜子)
TotalCoin int `json:"total_coin"`
Gold int `json:"gold"`
// Medal interface{} `json:"medal"`
Metadata string `json:"metadata"`
NewMedal int `json:"newMedal"`
NewTitle int `json:"newTitle"`
// NoticeMsg interface{} `json:"notice_msg"`
Num int `json:"num"`
Price int `json:"price"`
Rcost int `json:"rcost"`
Remain int `json:"remain"`
Rnd string `json:"rnd"`
Silver int `json:"silver"`
// SmalltvMsg interface{} `json:"smalltv_msg"`
// SpecialGift interface{} `json:"specialGift"`
Super int `json:"super"`
Timestamp int `json:"timestamp"`
Title string `json:"title"`
TopList *[]struct {
Face string `json:"face"`
GuardLevel int `json:"guard_level"`
IsSelf int `json:"isSelf"`
Rank int `json:"rank"`
Score int `json:"score"`
UID int `json:"uid"`
Uname string `json:"uname"`
} `json:"top_list"`
UID int `json:"uid"`
Uname string `json:"uname"`
Face string `json:"face"`
}
GiftInfo 礼物信息
type HandleFunc ¶
type HandleFunc func(c *Context)
func (HandleFunc) HandleFunc ¶
func (f HandleFunc) HandleFunc(context *Context)
type SuperChatMsg ¶
type SuperChatMsg struct {
Id int64 `json:"id"`
Uid int64 `json:"uid"` // 用户id
Price float64 `json:"price"` // 价值
Rate float64 `json:"rate"` // (可能是金瓜子与rmb的比例)
Message string `json:"message"` // 留言消息
TransMark int `json:"trans_mark"`
IsRanked int `json:"is_ranked"`
MessageTrans string `json:"message_trans"`
BackgroundImage string `json:"background_image"`
BackgroundColor string `json:"background_color"`
BackgroundIcon string `json:"background_icon"`
BackgroundPriceColor string `json:"background_price_color"`
BackgroundBottomColor string `json:"background_bottom_color"`
Ts int64 `json:"ts"`
Token string `json:"token"`
// MedalInfo object
UserInfo struct {
Uname string `json:"uname"`
Face string `json:"face"`
FaceFrame string `json:"face_frame"`
GuardLevel int `json:"guard_level"`
UserLevel int `json:"user_level"`
LevelColor string `json:"level_color"`
IsVip int `json:"is_vip"`
IsSvip int `json:"is_svip"`
IsMainVip int `json:"is_main_vip"`
Title string `json:"title"`
Manager int `json:"manager"`
} `json:"user_info"` // 用户信息
Time int64 `json:"time"` // 持续秒
StartTime int64 `json:"start_time"` // 开始时间戳
EndTime int64 `json:"end_time"` // 结束时间戳
Gift struct {
Num int `json:"num"`
GiftId int `json:"gift_id"`
GiftName string `json:"gift_name"`
} `json:"gift"`
}
type WelcomeGuardInfo ¶
type WelcomeGuardInfo struct {
GuardLevel string `json:"guard_level"`
UID int `json:"uid"`
Username string `json:"username"`
}
WelcomeGuardInfo 管理进房信息
Click to show internal directories.
Click to hide internal directories.