You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nnet/packet/interface.go

24 lines
654 B
Go

package packet
import "git.noahlan.cn/northlan/nnet/nface"
// Type 数据帧类型,如:握手,心跳,数据等
type Type byte
type (
Packer interface {
// Pack 从原始raw bytes创建一个用于网络传输的 packet.Packet 结构
Pack(typ Type, data []byte) ([]byte, error)
// Unpack 解包
Unpack(data []byte) ([]interface{}, error)
}
// Processor 数据帧处理器,拆包之后的处理
Processor interface {
// ProcessPacket 单个数据包处理方法
// packet 为实际数据包,是 packet.Packer 的Unpack方法拆包出来的数据指针
ProcessPacket(conn nface.IConnection, packet interface{}) error
}
)