1 Star 1 Fork 0

hXoreyer/knet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
message.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Kris 提交于 2021-12-09 17:02 . v1.0.0
package knet
/*
请求消息模块
*/
type IMessage interface {
//获取消息ID
GetID() uint32
//获取数据长度
GetLen() uint32
//获取数据
GetData() []byte
//设置消息ID
SetID(uint32)
//设置数据长度
SetLen(uint32)
//设置数据
SetData([]byte)
}
type Message struct {
Id uint32 //消息ID
DataLen uint32 //数据长度
Data []byte //数据
}
//获取消息ID
func (m *Message) GetID() uint32 {
return m.Id
}
//获取数据长度
func (m *Message) GetLen() uint32 {
return m.DataLen
}
//获取数据
func (m *Message) GetData() []byte {
return m.Data
}
//设置消息ID
func (m *Message) SetID(id uint32) {
m.Id = id
}
//设置数据长度
func (m *Message) SetLen(len uint32) {
m.DataLen = len
}
//设置数据
func (m *Message) SetData(data []byte) {
m.Data = data
}
//实例化
func NewMessage(id uint32, data []byte) IMessage {
return &Message{
Id: id,
DataLen: uint32(len(data)),
Data: data,
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/hXoreyer/knet.git
git@gitee.com:hXoreyer/knet.git
hXoreyer
knet
knet
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385