protocol

package
v1.3.78 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultHeadLengthBytes = 2
	DefHeadLength          = 6

	DefaultHeadLength = 8

	DefaultProtocolVersion = 0x8001 // test protocol version

	ActionPing = 0x0001 // ping
	ActionPong = 0x0002 // pong
	ActionData = 0x00F0 // business
)

default custom protocol const

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomLengthFieldProtocol

type CustomLengthFieldProtocol struct {
	Version    uint16
	ActionType uint16
	DataLength uint32
	Data       []byte
}

CustomLengthFieldProtocol : custom protocol custom protocol header contains Version, ActionType and DataLength fields its payload is Data field

func (*CustomLengthFieldProtocol) Decode

func (cc *CustomLengthFieldProtocol) Decode(c gnet.Conn, dataFrame interface{}) (interface{}, error)

Decode ...

func (*CustomLengthFieldProtocol) Encode

func (cc *CustomLengthFieldProtocol) Encode(dataFrame interface{}) ([]byte, error)

Encode ...

type NimProtocol

type NimProtocol struct {
	HeaderLength uint16
	CmdId        uint16
	BodyLength   uint16
	Body         []byte
}

its payload is Data field

func (*NimProtocol) Decode

func (cc *NimProtocol) Decode(c gnet.Conn, dataFrame interface{}) (interface{}, error)

Decode ...

func (*NimProtocol) Encode

func (cc *NimProtocol) Encode(dataFrame interface{}) ([]byte, error)

Encode ...

Jump to

Keyboard shortcuts

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