Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( HeadLength = 4 // 4 bytes MaxPacketSize = 1 << 24 // 16mb )
Functions ¶
func BytesToInt ¶
BytesToInt Decode packet data length byte to int(Big end)
func IntToBytes ¶
IntToBytes Encode packet data length to bytes(Big end)
func InvalidType ¶
Types ¶
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
type PomeloCodec ¶
type PomeloCodec struct { }
func NewPomeloCodec ¶
func NewPomeloCodec() *PomeloCodec
func (*PomeloCodec) PacketDecode ¶
func (p *PomeloCodec) PacketDecode(data []byte) ([]cherryFacade.IPacket, error)
func (*PomeloCodec) PacketEncode ¶
func (p *PomeloCodec) PacketEncode(typ byte, data []byte) ([]byte, error)
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
type Type ¶
type Type = byte
const ( None Type = 0x00 // None Handshake Type = 0x01 // Handshake represents a handshake: request(client) <====> handshake response(server) HandshakeAck Type = 0x02 // HandshakeAck represents a handshake ack from client to server Heartbeat Type = 0x03 // Heartbeat represents a heartbeat Data Type = 0x04 // settings represents a common data packet Kick Type = 0x05 // Kick represents a kick off packet )
func ParseHeader ¶
ParseHeader parses a packet header and returns its dataLen and packetType or an error
Click to show internal directories.
Click to hide internal directories.