cherryPacketPomelo

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 3 Imported by: 0

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.

View Source
var SessionStatus = map[int]string{
	Inited:  "inited",
	WaitAck: "wait_ack",
	Working: "working",
	Closed:  "closed",
}

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
}

func NewDecoder

func NewDecoder() *Decoder

func (*Decoder) Decode

func (p *Decoder) Decode(data []byte) ([]*cherryInterfaces.Packet, error)

type Encoder

type Encoder struct {
}

func NewEncoder

func NewEncoder() *Encoder

func (*Encoder) Encode

func (p *Encoder) Encode(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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL