Documentation
¶
Index ¶
Constants ¶
View Source
const ( Inited = iota WaitAck Working Closed )
View Source
const ( // Handshake represents a handshake: request(client) <====> handshake response(server) Handshake = 0x01 // HandshakeAck represents a handshake ack from client to server HandshakeAck = 0x02 // Heartbeat represents a heartbeat Heartbeat = 0x03 // Settings represents a common data packet Data = 0x04 // Kick represents a kick off packet Kick = 0x05 // disconnect message from server )
View Source
const ( HeadLength = 4 //4 bytes MaxPacketSize = 1 << 24 //16mb )
Variables ¶
View Source
var ( ErrWrongPacketType = errors.New("wrong packet type") // ErrPacketSizeExcced is the error used for encode/decode. ErrPacketSizeExcced = errors.New("codec: packet size exceed") )
var error
View Source
var ErrWrongPomeloPacketType = errors.New("wrong packet type")
ErrWrongPomeloPacketType represents a wrong packet type.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder struct {
}
func NewEncoder ¶
func NewEncoder() *Encoder
func (*Encoder) Encode ¶
PacketEncode 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.