client

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: AGPL-3.0 Imports: 12 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"
	BiliUrl        = "www.bilibili.com"
	BiliLiveApiUrl = "api.live.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
)

Variables

View Source
var JsonCoder jsonCoder
View Source
var RespCodeNotError = errors.New("resp code not 0")

Functions

This section is empty.

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"`
}

func GetLiveRoomAuth

func GetLiveRoomAuth(roomId int) (ApiLiveAuth, error)

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      int    `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