bilibili

package
v0.0.0-...-631691c Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_LENGTH = 16 // in bytes
	DEVICE_TYPE   = 1
	DEVICE        = 1
)
View Source
const (
	// cmd types
	DANMU_MSG = "DANMU_MSG"

	//
	SERVER_PORT = "2243"
)

Variables

This section is empty.

Functions

func GetBarrageServerAndLiveState

func GetBarrageServerAndLiveState(room string) (string, string, error)

func GetRoomId

func GetRoomId(uri string) (string, error)

func RandUser

func RandUser() int

Types

type Client

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

func Connect

func Connect(uri string, uid int, handlerRegister *HandlerRegister) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

Close connnection

func (*Client) Receive

func (c *Client) Receive() ([]byte, int, error)

func (*Client) Send

func (c *Client) Send(b []byte) (int, error)

func (*Client) Serve

func (c *Client) Serve()

type Handler

type Handler func(*Message)

Handler: message function wrapper

type HandlerRegister

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

HandlerRegister: message handler manager

func CreateHandlerRegister

func CreateHandlerRegister() *HandlerRegister

CreateHandlerRegister: create handler register

func (*HandlerRegister) Add

func (hr *HandlerRegister) Add(key string, h Handler, name string) error

Add: add message callback handle to handler register

func (*HandlerRegister) DisableByName

func (hr *HandlerRegister) DisableByName(name string) error

DisableByName: disable message handler by name

func (*HandlerRegister) DisableByType

func (hr *HandlerRegister) DisableByType(key string) error

DisableByType: disable handler by message type

func (*HandlerRegister) Dump

func (hr *HandlerRegister) Dump() string

Dump: output all message handlers

func (*HandlerRegister) EnableByName

func (hr *HandlerRegister) EnableByName(name string) error

EnableByName: enable message handler by name

func (*HandlerRegister) EnableByType

func (hr *HandlerRegister) EnableByType(key string) error

EnableByType: enable handler by message type

func (*HandlerRegister) Get

func (hr *HandlerRegister) Get(key string) (error, []*HandlerWrapper)

Get: get message handler

type HandlerWrapper

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

HandlerWrapper: message handler wrapper

func (*HandlerWrapper) Run

func (s *HandlerWrapper) Run(msg *Message)

Run: message handler callback

type Message

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

func NewHandshakeMessage

func NewHandshakeMessage(roomid, uid int) *Message

func NewHeartbeatMessage

func NewHeartbeatMessage(room, uid int) *Message

func NewMessage

func NewMessage(b []byte, btype int) *Message

func (*Message) Bytes

func (msg *Message) Bytes() []byte

func (*Message) Decode

func (msg *Message) Decode() *Message

func (*Message) Encode

func (msg *Message) Encode() []byte

func (*Message) GetCmd

func (msg *Message) GetCmd() string

Jump to

Keyboard shortcuts

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