live

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WsBodyProtocolVersionNormal = 0
	WsBodyProtocolVersionZlib   = 2
	WsBodyProtocolVersionBrotli = 3

	WsOpHeartbeat          = 2
	WsOpHeartbeatReply     = 3
	WsOpMessage            = 5
	WsOpUserAuthentication = 7
	WsOpConnectSuccess     = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(base *base.Base) *API

func (*API) WebRoomInfo

func (a *API) WebRoomInfo(opt WebRoomInfoOpt) (*WebRoomInfoResp, error)

获取信息流认证秘钥 https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/live/message_stream.md#获取信息流认证秘钥

type Config

type Config struct {
	NoSecure           bool
	ReadHeartbeatReply bool
	HeartBeatInterval  time.Duration
	MsgCap             int
	Log                base.BaseLogger
	AuthInfo           UserAuth
	HostList           []LiveHost
	CookieJar          http.CookieJar
	UserAgent          string
	Dialer             *websocket.Dialer
	Header             http.Header
}

type Live

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

func NewLive

func NewLive(ctx context.Context, cfg Config) (*Live, error)

func (*Live) Close

func (l *Live) Close()

func (*Live) ReadWsMsg

func (l *Live) ReadWsMsg(ctx context.Context) (WsSubMsg, error)

type LiveHost

type LiveHost struct {
	Host    string `json:"host"`
	Port    int    `json:"port"`
	WssPort int    `json:"wss_port"`
	WsPort  int    `json:"ws_port"`
}

type UserAuth

type UserAuth struct {
	UID      int64  `json:"uid"`
	RoomID   int64  `json:"roomid"`
	ProtoVer int    `json:"protover"`
	Platform string `json:"platform"`
	Type     int    `json:"type"`
	Key      string `json:"key"`
}

type WebRoomInfoOpt

type WebRoomInfoOpt struct {
	ID   int64 `url:"id"`             // 直播间真实 ID
	Type int   `url:"type,omitempry"` // ?类型, 默认为 0
}

type WebRoomInfoResp

type WebRoomInfoResp 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         []LiveHost `json:"host_list"`
}

type WsSubMsg

type WsSubMsg struct {
	Ver  uint16
	Op   uint32
	Cmd  string
	Body []byte
}

type WsSubPkt

type WsSubPkt []byte

func NewWsSubPkt

func NewWsSubPkt(ver uint16, op uint32, payload []byte) WsSubPkt

func ReadWsSubPkt

func ReadWsSubPkt(r io.Reader) (WsSubPkt, error)

func (WsSubPkt) Body

func (m WsSubPkt) Body() []byte

func (WsSubPkt) HdrLen

func (m WsSubPkt) HdrLen() uint16

func (WsSubPkt) Operation

func (m WsSubPkt) Operation() uint32

func (WsSubPkt) PktLen

func (m WsSubPkt) PktLen() uint32

func (WsSubPkt) Sequence

func (m WsSubPkt) Sequence() uint32

func (WsSubPkt) Version

func (m WsSubPkt) Version() uint16

Jump to

Keyboard shortcuts

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