Documentation
¶
Index ¶
- Constants
- Variables
- func MarshalV1(w io.Writer, pkt fatchoy.IPacket, encryptor cipher.BlockCryptor) (int, error)
- func MarshalV2(w io.Writer, pkt fatchoy.IPacket, encryptor cipher.BlockCryptor) (int, error)
- func ReadLenData(r io.Reader) ([]byte, error)
- func ReadPacketV1(r io.Reader, decrypt cipher.BlockCryptor, pkt fatchoy.IPacket) error
- func ReadPacketV2(r io.Reader, decrypt cipher.BlockCryptor, pkt fatchoy.IPacket) error
- func UnmarshalV1(head V1Header, payload []byte, decrypt cipher.BlockCryptor, ...) error
- func UnmarshalV2(head V2Header, payload []byte, decrypt cipher.BlockCryptor, ...) error
- func WriteLenData(w io.Writer, data []byte) (int, error)
- func WritePacketV1(w io.Writer, encrypt cipher.BlockCryptor, pkt fatchoy.IPacket) (int, error)
- func WritePacketV2(w io.Writer, encrypt cipher.BlockCryptor, pkt fatchoy.IPacket) (int, error)
- type V1Header
- func (h V1Header) CalcChecksum(payload []byte) uint32
- func (h V1Header) Checksum() uint32
- func (h V1Header) Command() int32
- func (h V1Header) Flag() uint8
- func (h V1Header) Len() uint16
- func (h V1Header) MD5Sum() string
- func (h V1Header) Pack(pkt fatchoy.IPacket, size uint16)
- func (h V1Header) Seq() uint16
- func (h V1Header) SetChecksum(crc uint32)
- func (h V1Header) Type() uint8
- type V2Header
- func (h V2Header) CalcChecksum(refer, payload []byte) uint32
- func (h V2Header) Checksum() uint32
- func (h V2Header) Command() int32
- func (h V2Header) Flag() uint8
- func (h V2Header) Len() uint32
- func (h V2Header) MD5Sum() string
- func (h V2Header) Node() fatchoy.NodeID
- func (h V2Header) Pack(pkt fatchoy.IPacket, nRef uint8, size uint32)
- func (h V2Header) RefCount() uint8
- func (h V2Header) Seq() uint16
- func (h V2Header) SetChecksum(crc uint32)
- func (h V2Header) Type() uint8
Constants ¶
View Source
const ( VersionV1 = 1 V1HeaderSize = 14 // 包头大小 V1MaxPayloadBytes = 60 * 1024 // 60K )
View Source
const ( VersionV2 = 2 V2HeaderSize = 20 // 包头大小 V2MaxPayloadBytes = 8 * 1024 * 1024 // 8M )
Variables ¶
View Source
var V1CompressThreshold = 4096 // 默认压缩阈值,4K
View Source
var V2CompressThreshold = 4096 // 默认压缩阈值,4K
Functions ¶
func ReadPacketV1 ¶
读取一个packet
func ReadPacketV2 ¶
读取一个packet
func UnmarshalV1 ¶
func UnmarshalV1(head V1Header, payload []byte, decrypt cipher.BlockCryptor, pkt fatchoy.IPacket) error
解码消息到pkt
func UnmarshalV2 ¶
func UnmarshalV2(head V2Header, payload []byte, decrypt cipher.BlockCryptor, pkt fatchoy.IPacket) error
解码消息到pkt
func WritePacketV1 ¶
写入一个packet
func WritePacketV2 ¶
写入一个packet
Types ¶
type V1Header ¶
type V1Header []byte
func (V1Header) SetChecksum ¶
type V2Header ¶
type V2Header []byte
func (V2Header) CalcChecksum ¶
校验码包含head和body
func (V2Header) SetChecksum ¶
Click to show internal directories.
Click to hide internal directories.