packet

package
v0.0.0-...-2f9bf8d Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(data []byte) []byte

Compress 压缩数据

func PackBoolean

func PackBoolean(b bool) byte

PackBoolean 打包一个布尔值

func PackDouble

func PackDouble(d float64) (p []byte)

PackDouble 打包一个64位浮点数

func PackFloat

func PackFloat(f float32) (p []byte)

PackFloat 打包一个32位浮点数

func PackPosition

func PackPosition(x, y, z int) (p []byte)

PackPosition 打包一个位置

func PackString

func PackString(s string) (p []byte)

PackString 打包一个字符串

func PackUint16

func PackUint16(n uint16) (p []byte)

PackUint16 打包一个16位无符号整数

func PackUint32

func PackUint32(n uint32) (p []byte)

PackUint32 打包一个32位无符号整数

func PackUint64

func PackUint64(n uint64) (p []byte)

PackUint64 打包一个64位无符号整数

func PackVarInt

func PackVarInt(n int32) (VarInt []byte)

PackVarInt 打包一个VarInt

func ReadNBytes

func ReadNBytes(b io.ByteReader, n int) (bs []byte, err error)

ReadNBytes read N bytes from bytes.Reader

func UnpackDouble

func UnpackDouble(b io.ByteReader) (float64, error)

UnpackDouble 读取一个双精度浮点数

func UnpackFloat

func UnpackFloat(b io.ByteReader) (float32, error)

UnpackFloat 读取一个单精度浮点数

func UnpackInt16

func UnpackInt16(b io.ByteReader) (int16, error)

UnpackInt16 读取一个16位有符号整数

func UnpackInt32

func UnpackInt32(b io.ByteReader) (int32, error)

UnpackInt32 读取一个32位有符号整数

func UnpackInt64

func UnpackInt64(b io.ByteReader) (int64, error)

UnpackInt64 读取一个64位有符号整数

func UnpackPosition

func UnpackPosition(b io.ByteReader) (x, y, z int, err error)

UnpackPosition 读取一个位置

func UnpackString

func UnpackString(b io.ByteReader) (s string, err error)

UnpackString 读取一个字符串

func UnpackVarInt

func UnpackVarInt(b io.ByteReader) (int32, error)

UnpackVarInt 读取一个VarInt

Types

type Packet

type Packet struct {
	ID   byte
	Data []byte
}

Packet define a net data package

func RecvPacket

func RecvPacket(r io.ByteReader, useZlib bool) (*Packet, error)

RecvPacket recive a packet from server

func UnCompress

func UnCompress(data []byte) (*Packet, error)

UnCompress 读取一个压缩的包

func (*Packet) Pack

func (p *Packet) Pack(threshold int) (pack []byte)

Pack 打包一个数据包

Jump to

Keyboard shortcuts

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