message

package
v0.0.0-...-6384d94 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartBeat = PacketType(iota)
	Command
	Data
)
View Source
const HeaderLen int32 = 6

HeaderLen packet header length

View Source
const MessageVersion string = "1.0.0.0"
View Source
const PacketVersion byte = 0x2B

PacketVersion the default version of packet

Variables

This section is empty.

Functions

func GetCommandBytes

func GetCommandBytes(t CmdType, o interface{}) []byte

GetCommandBytes ...

func GetDataMsgBytes

func GetDataMsgBytes(id []byte, offset int64, data []byte) []byte

GetDataMsgBytes ...

func GetHeartBeatBytes

func GetHeartBeatBytes() []byte

GetHeartBeatBytes ...

func ParsePacket

func ParsePacket(cc net.Conn, callback ParseCallback) (bool, error)

Types

type CmdType

type CmdType int32

CmdType is the Type of Command

type Message

type Message struct {
	Name    string `json:"-"`
	ID      string `json:"id"`
	Version string `json:"version"`
}

Message is the payload of the packet

func (Message) String

func (message Message) String() string

type Packet

type Packet struct {
	Version byte
	Type    PacketType
	Length  int32
	Payload []byte
}

Packet is the tcp packet data format | description | version | type | length | payload | | size(byte) | 1 | 1 | 4 | length | when the type is heartbeat(0x00), there is no Length and Payload field

type PacketType

type PacketType byte

PacketType raw packet type

type ParseCallback

type ParseCallback func(net.Conn, *Packet)

Jump to

Keyboard shortcuts

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