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 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
func IntToBytes ¶
IntToBytes Encode packet data length to bytes(Big end)
func InvalidType ¶
func ParseHeader ¶
ParseHeader parses a packet header and returns its dataLen and packetType or an error
Types ¶
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
type Type ¶
type Type = byte // packet type
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 )
Click to show internal directories.
Click to hide internal directories.