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/protocol/plain/packet_plain.go

32 lines
490 B
Go

package plain
import (
"encoding/hex"
"fmt"
)
type Packet struct {
Data []byte // 原始数据
}
func newPacket() *Packet {
return &Packet{}
}
func (p *Packet) GetHeader() any {
return nil
}
func (p *Packet) GetLen() uint64 {
return uint64(len(p.Data))
}
func (p *Packet) GetBody() []byte {
return p.Data
}
func (p *Packet) String() string {
return fmt.Sprintf("PlainPacket[Len: %d] BodyStr: [%s], BodyHex: [%s]",
len(p.Data), string(p.Data), hex.EncodeToString(p.Data))
}