Documentation ¶
Index ¶
- Constants
- func GetCommandBytes(t CmdType, o interface{}) []byte
- func GetDataMsgBytes(id []byte, offset int64, data []byte) []byte
- func GetHeartBeatBytes() []byte
- func ParsePacket(cc net.Conn, callback ParseCallback) (bool, error)
- type CmdType
- type Message
- type Packet
- type PacketType
- type ParseCallback
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 GetDataMsgBytes ¶
GetDataMsgBytes ...
func ParsePacket ¶
func ParsePacket(cc net.Conn, callback ParseCallback) (bool, error)
Types ¶
type Message ¶
type Message struct { Name string `json:"-"` ID string `json:"id"` Version string `json:"version"` }
Message is the payload of the packet
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 ParseCallback ¶
Click to show internal directories.
Click to hide internal directories.