websocket

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

websocket部分

添加一个新的事件handler

使用hygen
hygen event new EVENT_NAME
手动
  • dto目录下添加一个新的dto文件
  • dto/webscoket_event中添加一个新的event
  • websocket/handler_registration中添加事件handler类型
  • websocket/handler_registration中的DefaultHandlersRegisterHandlers添加事件注册
  • websocket/handler_eventeventPayloadHandlerMap添加事件处理器

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEventHandlers struct {
	Live                          LiveHandler
	Preparing                     PreparingHandler
	Danmaku                       DanmakuHandler
	Gift                          GiftHandler
	SuperChat                     SuperChatHandler
	SuperChatDelete               SuperChatDeleteHandler
	Guard                         GuardHandler
	Popularity                    PopularityHandler
	EntryEffect                   EntryEffectHandler
	InteractWord                  InteractWordHandler
	ComboSend                     ComboSendHandler
	FansChange                    FansChangeHandler
	InteractiveGame               InteractiveGameHandler
	OnlineRankCount               OnlineRankCountHandler
	HotRankChanged                HotRankChangedHandler
	HotRankChangedV2              HotRankChangedV2Handler
	HotRankSettlement             HotRankSettlementHandler
	HotRankSettlementV2           HotRankSettlementV2Handler
	OnlineRankTop3                OnlineRankTop3Handler
	OnlineRankV2                  OnlineRankV2Handler
	StopLiveRoomList              StopLiveRoomListHandler
	WatchedChange                 WatchedChangeHandler
	WidgetBanner                  WidgetBannerHandler
	PopularityRedPocketStart      PopularityRedPocketStartHandler
	PopularityRedPocketWinnerList PopularityRedPocketWinnerListHandler
	NoticeMsg                     NoticeMsgHandler
	AnchorLotAward                AnchorLotAwardHandler
	UserToastMsg                  UserToastMsgHandler
	RoomChange                    RoomChangeHandler
	RoomBlockMsg                  RoomBlockMsgHandler
	MatchRoomConf                 MatchRoomConfHandler
	CommonNoticeDanmaku           CommonNoticeDanmakuHandler
	AnchorLotCheckstatus          AnchorLotCheckStatusHandler
	AnchorLotEnd                  AnchorLotEndHandler
	AnchorLotStart                AnchorLotStartHandler
	TradingScore                  TradingScoreHandler
	// handler_struct above(for hygen)
	UnknownEvent UnknownEventHandler
}

DefaultEventHandlers 默认事件处理器,由 RegisterHandlers 注册

Functions

func Decode

func Decode(data []byte) *dto.WSPayload

Decode 将二进制数据转换为 *dto.WSPayload 类型

func Encode

func Encode(p *dto.WSPayload) []byte

Encode 将 *dto.WSPayload 类型转换为二进制数据

func RegisterHandlers

func RegisterHandlers(handlers ...interface{}) error

RegisterHandlers 注册事件处理函数

Types

type AnchorLotAwardHandler

type AnchorLotAwardHandler func(anchorLotAward *dto.AnchorLotAward)

AnchorLotAwardHandler 天选之人中奖完整信息

type AnchorLotCheckStatusHandler

type AnchorLotCheckStatusHandler func(anchorLotCheckStatus *dto.AnchorLotCheckStatus)

AnchorLotCheckStatusHandler 天选之人相关

type AnchorLotEndHandler

type AnchorLotEndHandler func(anchorLotEnd *dto.AnchorLotEnd)

AnchorLotEndHandler 天选之人相关

type AnchorLotStartHandler

type AnchorLotStartHandler func(anchorLotStart *dto.AnchorLotStart)

AnchorLotStartHandler 天选之人抽奖开始

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client websocket客户端实例

func New

func New() *Client

New 创建websocket客户端

func (*Client) Close

func (c *Client) Close()

Close 关闭websocket连接,停止心跳

func (*Client) Connect

func (c *Client) Connect() error

Connect 连接到B站直播服务端

func (*Client) Listening

func (c *Client) Listening() error

Listening 开始心跳和消息监听,阻塞协程

func (*Client) Write

func (c *Client) Write(payload *dto.WSPayload) error

type ComboSendHandler

type ComboSendHandler func(comboSend *dto.ComboSend)

ComboSendHandler 礼物连击

type CommonNoticeDanmakuHandler

type CommonNoticeDanmakuHandler func(commonNoticeDanmaku *dto.CommonNoticeDanmaku)

CommonNoticeDanmakuHandler 提示信息,如'恭喜主播完成"小小花束"任务'

type DanmakuHandler

type DanmakuHandler func(danmaku *dto.Danmaku)

DanmakuHandler 弹幕

type EntryEffectHandler

type EntryEffectHandler func(entryEffect *dto.EntryEffect)

EntryEffectHandler 进入房间特效

type FansChangeHandler

type FansChangeHandler func(fansChange *dto.FansChange)

FansChangeHandler 粉丝变动

type GiftHandler

type GiftHandler func(gift *dto.Gift)

GiftHandler 礼物

type GuardHandler

type GuardHandler func(guard *dto.Guard)

GuardHandler 购买舰长

type HotRankChangedHandler

type HotRankChangedHandler func(hotRankChanged *dto.HotRankChanged)

HotRankChangedHandler 热度榜单变化

type HotRankChangedV2Handler

type HotRankChangedV2Handler func(hotRankChangedV2 *dto.HotRankChangedV2)

HotRankChangedV2Handler 热度榜单变化V2

type HotRankSettlementHandler

type HotRankSettlementHandler func(hotRankSettlement *dto.HotRankSettlement)

HotRankSettlementHandler 热度榜单结算

type HotRankSettlementV2Handler

type HotRankSettlementV2Handler func(hotRankSettlementV2 *dto.HotRankSettlementV2)

HotRankSettlementV2Handler 热度榜单结算V2

type InteractWordHandler

type InteractWordHandler func(interactWord *dto.InteractWord)

InteractWordHandler 发生互动

type InteractiveGameHandler

type InteractiveGameHandler func(interactiveGame *dto.InteractiveGame)

InteractiveGameHandler 游戏互动

type LiveHandler

type LiveHandler func()

LiveHandler 开播

type MatchRoomConfHandler

type MatchRoomConfHandler func(matchRoomConf *dto.MatchRoomConf)

MatchRoomConfHandler 未知

type NoticeMsgHandler

type NoticeMsgHandler func(noticeMsg *dto.NoticeMsg)

NoticeMsgHandler 公告消息

type OnlineRankCountHandler

type OnlineRankCountHandler func(onlineRankCount *dto.OnlineRankCount)

OnlineRankCountHandler 在线榜单

type OnlineRankTop3Handler

type OnlineRankTop3Handler func(onlineRankTop3 *dto.OnlineRankTop3)

OnlineRankTop3Handler 高能榜前三

type OnlineRankV2Handler

type OnlineRankV2Handler func(onlineRankV2 *dto.OnlineRankV2)

OnlineRankV2Handler 高能榜V2

type PopularityHandler

type PopularityHandler func(popularity uint32)

PopularityHandler 人气变动

type PopularityRedPocketStartHandler

type PopularityRedPocketStartHandler func(popularityRedPocketStart *dto.PopularityRedPocketStart)

PopularityRedPocketStartHandler 红包开始

type PopularityRedPocketWinnerListHandler

type PopularityRedPocketWinnerListHandler func(popularityRedPocketWinnerList *dto.PopularityRedPocketWinnerList)

PopularityRedPocketWinnerListHandler 红包中奖名单

type PreparingHandler

type PreparingHandler func()

PreparingHandler 下播

type RoomBlockMsgHandler

type RoomBlockMsgHandler func(roomBlockMsg *dto.RoomBlockMsg)

RoomBlockMsgHandler 房管禁言

type RoomChangeHandler

type RoomChangeHandler func(roomChange *dto.RoomChange)

RoomChangeHandler 疑似房间标题变更

type StopLiveRoomListHandler

type StopLiveRoomListHandler func(stopLiveRoomList *dto.StopLiveRoomList)

StopLiveRoomListHandler 停止直播列表

type SuperChatDeleteHandler

type SuperChatDeleteHandler func(superChat *dto.SuperChatDelete)

SuperChatDeleteHandler 删除超级留言

type SuperChatHandler

type SuperChatHandler func(superChat *dto.SuperChat)

SuperChatHandler 超级留言

type TradingScoreHandler

type TradingScoreHandler func(tradingScore *dto.TradingScore)

TradingScoreHandler 未知

type UnknownEventHandler

type UnknownEventHandler func(unknownEvent *dto.WSPayload)

UnknownEventHandler 未知消息

type UserToastMsgHandler

type UserToastMsgHandler func(userToastMsg *dto.UserToastMsg)

UserToastMsgHandler 弹幕栏中显示的toast信息,如xxx自动续费了舰长,xxx开通了舰长

type WatchedChangeHandler

type WatchedChangeHandler func(watchedChange *dto.WatchedChange)

WatchedChangeHandler 观看人数变化

type WidgetBannerHandler

type WidgetBannerHandler func(widgetBanner *dto.WidgetBanner)

WidgetBannerHandler 推广横幅

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL