codec

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDataNotEnough = io.ErrShortBuffer // 数据不足
)

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	MsgCreator gap.IMsgCreator // 消息对象构建器
	// contains filtered or unexported fields
}

Decoder 消息包解码器

func DefaultDecoder

func DefaultDecoder() Decoder

DefaultDecoder 默认消息包解码器

func MakeDecoder

func MakeDecoder(mc gap.IMsgCreator) Decoder

MakeDecoder 创建消息包解码器

func (*Decoder) Decode

func (d *Decoder) Decode() (gap.MsgPacket, error)

Decode 从缓存,解码消息包

func (Decoder) DecodeBuff

func (d Decoder) DecodeBuff(buff *bytes.Buffer) (gap.MsgPacket, error)

DecodeBuff 从指定buff,解码消息包

func (Decoder) DecodeBytes

func (d Decoder) DecodeBytes(data []byte) (gap.MsgPacket, error)

DecodeBytes 从指定bytes,解码消息包

func (*Decoder) ReadFrom

func (d *Decoder) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom

func (*Decoder) Reset

func (d *Decoder) Reset()

Reset 重置缓存

func (*Decoder) Write

func (d *Decoder) Write(p []byte) (int, error)

Write implements io.Writer

type Encoder

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

Encoder 消息包编码器

func DefaultEncoder

func DefaultEncoder() Encoder

DefaultEncoder 默认消息包编码器

func MakeEncoder

func MakeEncoder() Encoder

MakeEncoder 创建消息包编码器

func (*Encoder) Encode

func (e *Encoder) Encode(src string, seq int64, msg gap.Msg) error

Encode 编码消息包,写入缓存

func (Encoder) EncodeBuff

func (e Encoder) EncodeBuff(buff *bytes.Buffer, src string, seq int64, msg gap.Msg) error

EncodeBuff 编码消息包,写入指定buffer

func (Encoder) EncodeBytes

func (e Encoder) EncodeBytes(src string, seq int64, msg gap.Msg) (binaryutil.RecycleBytes, error)

EncodeBytes 编码消息包,返回可回收bytes

func (Encoder) EncodeWriter

func (e Encoder) EncodeWriter(writer io.Writer, src string, seq int64, msg gap.Msg) error

EncodeWriter 编码消息包,写入指定writer

func (*Encoder) Read

func (e *Encoder) Read(p []byte) (int, error)

Read implements io.Reader

func (*Encoder) Reset

func (e *Encoder) Reset()

Reset 重置缓存

func (*Encoder) WriteTo

func (e *Encoder) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo

Jump to

Keyboard shortcuts

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