Documentation ¶
Overview ¶
Package msg micserver 中消息传递的基本单位
Index ¶
- Constants
- func DefaultWriteHead(data []byte, totalLen int, msgid uint16) (size int)
- type DefaultCodec
- type IMsgCodec
- type IMsgStruct
- type MessageBinary
- func (mb *MessageBinary) Free()
- func (mb *MessageBinary) GetBuffer() []byte
- func (mb *MessageBinary) GetMsgID() uint16
- func (mb *MessageBinary) GetProtoLength() int
- func (mb *MessageBinary) GetTotalLength() int
- func (mb *MessageBinary) Read(soffset int, data []byte, doffset int, bytenum int) error
- func (mb *MessageBinary) Reset()
- func (mb *MessageBinary) SetMsgID(v uint16)
- func (mb *MessageBinary) SetProtoDataBound(offset int, bytenum int) error
- func (mb *MessageBinary) SetProtoLength(v int)
- func (mb *MessageBinary) SetTotalLength(v int)
- func (mb *MessageBinary) String() string
Constants ¶
View Source
const (
DEFAULTMSGHEADSIZE = (4 + 2)
)
默认的消息头大小
View Source
const ( // MessageMaxSize 允许的最大消息大小(包括头部大小) // 普通代码中间应留出至少 32 字节提供给消息头部使用 MessageMaxSize = 8 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefaultCodec ¶
type DefaultCodec struct {
// contains filtered or unexported fields
}
DefaultCodec micserver 默认的消息编解码器
func (*DefaultCodec) EncodeBytes ¶
func (defaultCodec *DefaultCodec) EncodeBytes(cmdid uint16, protodata []byte) *MessageBinary
EncodeBytes 编码一个由消息号及二进制内容构成的消息
func (*DefaultCodec) EncodeObj ¶
func (defaultCodec *DefaultCodec) EncodeObj(v IMsgStruct) *MessageBinary
EncodeObj 编码一个消息对象
func (*DefaultCodec) RangeMsgBinary ¶
func (defaultCodec *DefaultCodec) RangeMsgBinary( buf *buffer.IOBuffer, cb func(*MessageBinary)) (reerr error)
RangeMsgBinary 遍历目标缓冲区中的消息
type IMsgCodec ¶
type IMsgCodec interface { RangeMsgBinary(buf *buffer.IOBuffer, cb func(*MessageBinary)) error EncodeBytes(cmdid uint16, protodata []byte) *MessageBinary EncodeObj(v IMsgStruct) *MessageBinary }
IMsgCodec 消息编解码器
type IMsgStruct ¶
type IMsgStruct interface { WriteBinary(data []byte) int GetMsgId() uint16 GetMsgName() string GetSize() int GetJSON() string }
IMsgStruct micserver消息接口,所有在micserver架构间的消息类都要满足这些接口
type MessageBinary ¶
type MessageBinary struct { msgbase.MessageBase ProtoData []byte // contains filtered or unexported fields }
MessageBinary micserver 中消息传递的基本单位
func DefaultEncodeBytes ¶
func DefaultEncodeBytes(cmdid uint16, protodata []byte) *MessageBinary
DefaultEncodeBytes 默认通过字节流构造消息体
func DefaultEncodeObj ¶
func DefaultEncodeObj(v IMsgStruct) *MessageBinary
DefaultEncodeObj 默认通过结构构造消息体
func GetMessageBinary ¶
func GetMessageBinary(totalLength int) *MessageBinary
GetMessageBinary 根据消息内容大小从对象池获取对应的消息对象
func (*MessageBinary) GetProtoLength ¶
func (mb *MessageBinary) GetProtoLength() int
GetProtoLength 获取消息包数据段总长度
func (*MessageBinary) GetTotalLength ¶
func (mb *MessageBinary) GetTotalLength() int
GetTotalLength 获取消息包二进制总长度
func (*MessageBinary) SetProtoDataBound ¶
func (mb *MessageBinary) SetProtoDataBound(offset int, bytenum int) error
SetProtoDataBound 设置消息内容数据域
func (*MessageBinary) SetProtoLength ¶
func (mb *MessageBinary) SetProtoLength(v int)
SetProtoLength 设置消息包数据段总长度
func (*MessageBinary) SetTotalLength ¶
func (mb *MessageBinary) SetTotalLength(v int)
SetTotalLength 设置消息包二进制总长度
Click to show internal directories.
Click to hide internal directories.