Documentation ¶
Index ¶
Constants ¶
const ( HeadLength = 4 MaxPacketSize = 64 * 1024 )
Codec constants.
Variables ¶
var ErrPacketSizeExcced = errors.New("codec: packet size exceed")
ErrPacketSizeExcced is the error used for encode/decode.
Functions ¶
This section is empty.
Types ¶
type PacketDecoder ¶
PacketDecoder interface
type PacketEncoder ¶
PacketEncoder interface
type PomeloPacketDecoder ¶
type PomeloPacketDecoder struct{}
PomeloPacketDecoder reads and decodes network data slice following pomelo's protocol
func NewPomeloPacketDecoder ¶
func NewPomeloPacketDecoder() *PomeloPacketDecoder
NewPomeloPacketDecoder returns a new decoder that used for decode network bytes slice.
type PomeloPacketEncoder ¶
type PomeloPacketEncoder struct { }
PomeloPacketEncoder struct
func NewPomeloPacketEncoder ¶
func NewPomeloPacketEncoder() *PomeloPacketEncoder
NewPomeloPacketEncoder ctor
func (*PomeloPacketEncoder) Encode ¶
Encode create a packet.Packet from the raw bytes slice and then encode to network bytes slice Protocol refs: https://github.com/NetEase/pomelo/wiki/Communication-Protocol
-<type>-|--------<length>--------|-<data>- --------|------------------------|-------- 1 byte packet type, 3 bytes packet data length(big end), and data segment