Documentation ¶
Index ¶
- Constants
- func EncodePacket(packet Packet) []byte
- func NewEnterPacket(ctx context.Context, uid int, buvid string, roomID int, key string) []byte
- func NewHeartBeatPacket(ctx context.Context) []byte
- type Enter
- type Packet
- func DecodePacket(ctx context.Context, data []byte) Packet
- func NewPacket(ctx context.Context, protocolVersion uint16, operation uint32, body []byte) Packet
- func NewPacketFromBytes(ctx context.Context, data []byte) Packet
- func NewPlainPacket(ctx context.Context, operation int, body []byte) Packet
- func Slice(ctx context.Context, data []byte) []Packet
Constants ¶
View Source
const ( Plain = iota Popularity Zlib Brotli )
View Source
const ( HandShake = iota HandShakeResponse HeartBeat HeartBeatResponse Notification RoomEnter RoomEnterResponse )
Variables ¶
This section is empty.
Functions ¶
func NewEnterPacket ¶
NewEnterPacket 构造进入房间的包 uid 可以为 0, key 在使用 broadcastlv 服务器的时候不需要
func NewHeartBeatPacket ¶
NewHeartBeatPacket 构造心跳包
Types ¶
type Packet ¶
type Packet struct { PacketLength int // PacketLength 在 build 时会计算 HeaderLength int // HeaderLength 大概是固定值 16 ProtocolVersion uint16 Operation uint32 SequenceID int Body []byte // contains filtered or unexported fields }
func NewPlainPacket ¶
NewPlainPacket 构造新的 Plain 包 对外暴露的方法中 operation 全部使用int
Click to show internal directories.
Click to hide internal directories.