Documentation
¶
Index ¶
- Constants
- func Depack(rawData []byte) (rawDataLocal []byte, outPacks []interface{}, bOk bool, strErrMsg string)
- func Htonl32(iNum uint32) []byte
- func Htonll64(iNum uint64) []byte
- func Ntohl32(byData []byte) (uint32, bool)
- func Ntohll64(byData []byte) (uint64, bool)
- func Pack(msg interface{}, timestamp uint32) ([]byte, bool, string)
- type EchoMsg
Constants ¶
View Source
const ( // NetPackHeadSize head size, fixed 12 bytes NetPackHeadSize = 12 // NetPackBeginstrSize head begin string size NetPackBeginstrSize = 4 // NetPackTimestampSize head timestamp size NetPackTimestampSize = 4 // NetPackDataLenSize head DataLen size NetPackDataLenSize = 4 )
Variables ¶
This section is empty.
Functions ¶
func Depack ¶
func Depack(rawData []byte) (rawDataLocal []byte, outPacks []interface{}, bOk bool, strErrMsg string)
Depack depack
@param rawData []byte : origin data @return []byte : data left after depack @return *list.List[]NetPacket : depacked package lists @return bool : is depack success
true -- success false -- have error, check errMsg
@return string : err msgs when depack
Types ¶
type EchoMsg ¶
type EchoMsg struct { // BeginString 4byte 0-3 BeginString [4]byte // Timestamp 4byte 4-7 Timestamp uint32 // DataLen RawData length 8-11 DataLen uint32 // RawData RawData []byte }
EchoMsg message sends between client and server
it will be like
0 11 DataLen | -- HEAD -- | -- RawData -- |
Click to show internal directories.
Click to hide internal directories.