Documentation ¶
Index ¶
Constants ¶
View Source
const ( HeadLength = 4 MaxPacketSize = 1 << 24 //16MB )
Codec constants.
Variables ¶
View Source
var ErrPacketSizeExceed = errors.New("codec: packet size exceed")
ErrPacketSizeExceed is the error used for encode/decode.
Functions ¶
func BytesToInt ¶
BytesToInt decode packet data length byte to int(Big end)
func IntToBytes ¶
IntToBytes encode packet data length to bytes(Big end)
Types ¶
type PomeloDecoder ¶
type PomeloDecoder struct { }
func NewPomeloDecoder ¶
func NewPomeloDecoder() *PomeloDecoder
type PomeloEncoder ¶
type PomeloEncoder struct { }
PomeloEncoder struct
func (*PomeloEncoder) 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
Click to show internal directories.
Click to hide internal directories.