client

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent      = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
	BiliLiveApiUrl = "api.live.bilibili.com"
	MainWsUrl      = "broadcastlv.chat.bilibili.com"
)
View Source
const (
	AuthProto      = 1
	HeartBeatProto = 1
	CmdZlibProto   = 2
	CmdBrotliProto = 3
)
View Source
const (
	OpError          = 1
	OpHeartBeat      = 2
	OpHeartBeatReply = 3
	OpCmd            = 5
	OpAuth           = 7
	OpAuthReply      = 8
)
View Source
const DefaultPriority = 1 << 0
View Source
const DelayPriority = 1 << 1
View Source
const NoCDNPriority = 1 << 2

Variables

View Source
var Header http.Header
View Source
var HeartBeatReplyCmd = "HEARTBEAT_REPLY"
View Source
var INF = 0x3f3f3f
View Source
var JsonCoder jsonCoder
View Source
var PriorityMode = DefaultPriority
View Source
var RespCodeNotError = errors.New("resp code not 0")
View Source
var UID = int64(1)

Functions

func ChangeSequenceMode added in v0.4.0

func ChangeSequenceMode(mode int)

func GetRealRoomId added in v0.4.0

func GetRealRoomId(roomId int) (int, error)

Types

type ApiLiveAuth

type ApiLiveAuth struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	TTL     int    `json:"ttl"`
	Data    struct {
		Group            string  `json:"group"`
		BusinessID       int     `json:"business_id"`
		RefreshRowFactor float64 `json:"refresh_row_factor"`
		RefreshRate      int     `json:"refresh_rate"`
		MaxDelay         int     `json:"max_delay"`
		Token            string  `json:"token"`
		HostList         []struct {
			Host    string `json:"host"`
			Port    int    `json:"port"`
			WssPort int    `json:"wss_port"`
			WsPort  int    `json:"ws_port"`
		} `json:"host_list"`
	} `json:"data"`
}

type ApiLiveRoomId added in v0.4.0

type ApiLiveRoomId struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	TTL     int    `json:"ttl"`
	Data    struct {
		RoomID          int           `json:"room_id"`
		ShortID         int           `json:"short_id"`
		UID             int           `json:"uid"`
		NeedP2P         int           `json:"need_p2p"`
		IsHidden        bool          `json:"is_hidden"`
		IsLocked        bool          `json:"is_locked"`
		IsPortrait      bool          `json:"is_portrait"`
		LiveStatus      int           `json:"live_status"`
		HiddenTill      int           `json:"hidden_till"`
		LockTill        int           `json:"lock_till"`
		Encrypted       bool          `json:"encrypted"`
		PwdVerified     bool          `json:"pwd_verified"`
		LiveTime        int           `json:"live_time"`
		RoomShield      int           `json:"room_shield"`
		IsSp            int           `json:"is_sp"`
		SpecialType     int           `json:"special_type"`
		PlayURL         interface{}   `json:"play_url"`
		AllSpecialTypes []interface{} `json:"all_special_types"`
	} `json:"data"`
}

type Client

type Client struct {
	// 一个直播间的状态: 关闭 / 已连接 / 连接中
	RoomId    int
	Connected bool
	// contains filtered or unexported fields
}

func (*Client) BiliChat

func (c *Client) BiliChat(CmdChan chan map[string]interface{})

func (*Client) Close

func (c *Client) Close()

type MsgHandler

type MsgHandler struct {
	RoomId  int
	CmdChan chan map[string]interface{}
}

func (*MsgHandler) CmdBrotliProtoDecoder

func (msgHandler *MsgHandler) CmdBrotliProtoDecoder(wsHeader *WsHeader, msg []byte) []byte

func (*MsgHandler) CmdHandler

func (msgHandler *MsgHandler) CmdHandler(wsHeader *WsHeader, msg []byte)

func (*MsgHandler) CmdZlibProtoDecoder

func (msgHandler *MsgHandler) CmdZlibProtoDecoder(wsHeader *WsHeader, msg []byte) []byte

func (*MsgHandler) MsgHandler

func (msgHandler *MsgHandler) MsgHandler(msg []byte)

type WsAuthBody

type WsAuthBody struct {
	UID      int64  `json:"uid"`
	Roomid   int    `json:"roomid"`
	Protover int    `json:"protover"`
	Platform string `json:"platform"`
	Type     int    `json:"type"`
	Key      string `json:"key"`
}

type WsAuthMessage

type WsAuthMessage struct {
	WsHeader WsHeader
	Body     WsAuthBody
}

func (*WsAuthMessage) GetPackage

func (wsAuth *WsAuthMessage) GetPackage() []byte

type WsAuthReplyBody

type WsAuthReplyBody struct {
	Code int `json:"code"`
}

type WsAuthReplyMessage

type WsAuthReplyMessage struct {
	WsHeader WsHeader
	Body     WsAuthReplyBody
}

func (*WsAuthReplyMessage) SetPackage

func (wsAuthReplyMessage *WsAuthReplyMessage) SetPackage(header WsHeader, msg []byte)

type WsCmdBrotliMessage

type WsCmdBrotliMessage struct {
	WsHeader WsHeader
	Body     []WsCmdMessage
}

type WsCmdMessage

type WsCmdMessage struct {
	WsHeader WsHeader
	Cmd      string
	Body     []byte
}

func (*WsCmdMessage) SetPackage

func (wsCmdMessage *WsCmdMessage) SetPackage(header WsHeader, msg []byte)

type WsHeader

type WsHeader struct {
	PackageLen uint32
	HeaderLen  uint16
	ProtoVer   uint16
	OpCode     uint32
	Sequence   uint32
}

func WsHeaderDecoder

func WsHeaderDecoder(headerBytes []byte) WsHeader

func (*WsHeader) HeaderEncoder

func (wsHeader *WsHeader) HeaderEncoder(bodyLen uint32) []byte

type WsHeartBeatMessage

type WsHeartBeatMessage struct {
	WsHeader WsHeader
	Body     []byte
}

func (*WsHeartBeatMessage) GetPackage

func (wsHeartBeat *WsHeartBeatMessage) GetPackage() []byte

type WsHeartBeatReply

type WsHeartBeatReply struct {
	WsHeader WsHeader
	Hot      uint32
	Msg      []byte
}

func (*WsHeartBeatReply) SetPackage

func (wsHeartBeatReply *WsHeartBeatReply) SetPackage(header WsHeader, msg []byte)

Jump to

Keyboard shortcuts

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