util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePackage

func DecodePackage(pkg *bytes.Buffer, recvData []byte) []byte

接收消息要处理粘包的解包函数或者TCP流处理 pkg是ConnectionSession的cache,如果根据头4个字节获取的报文长度大于当前pkg的len-4的长度,那么说明还有后续消息没有read,还需要继续等待。这时返回nil []byte 反之如果长度小于等于当前pkg的len-4的长度说明,说明已经获取了一个完整的消息,就把头四个字节去掉,然后把实际报文return出去

func EncodePackage

func EncodePackage(pkg *bytes.Buffer, data []byte) error

发消息时调用的组包函数

Types

This section is empty.

Jump to

Keyboard shortcuts

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