Documentation
¶
Index ¶
- type CustomCodec
- func (this *CustomCodec) CreatePacketHeader(connection gnet.Connection, packet gnet.Packet, packetData []byte) gnet.PacketHeader
- func (this *CustomCodec) Decode(connection gnet.Connection, data []byte) (newPacket gnet.Packet, err error)
- func (this *CustomCodec) Encode(connection gnet.Connection, packet gnet.Packet) []byte
- func (this *CustomCodec) PacketHeaderSize() uint32
- type CustomDataPacket
- func (this *CustomDataPacket) Clone() gnet.Packet
- func (this *CustomDataPacket) Command() gnet.PacketCommand
- func (this *CustomDataPacket) ErrorCode() uint32
- func (this *CustomDataPacket) GetStreamData() []byte
- func (this *CustomDataPacket) Message() proto.Message
- func (this *CustomDataPacket) RpcCallId() uint32
- func (this *CustomDataPacket) SetErrorCode(code uint32) *CustomDataPacket
- func (this *CustomDataPacket) SetRpcCallId(rpcCallId uint32)
- type CustomPacketHeader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomCodec ¶
type CustomCodec struct {
}
自定义编解码
func (*CustomCodec) CreatePacketHeader ¶
func (this *CustomCodec) CreatePacketHeader(connection gnet.Connection, packet gnet.Packet, packetData []byte) gnet.PacketHeader
使用CustomPacketHeader
func (*CustomCodec) Decode ¶
func (this *CustomCodec) Decode(connection gnet.Connection, data []byte) (newPacket gnet.Packet, err error)
这里的data是完整的包数据,包含了包头
func (*CustomCodec) Encode ¶
func (this *CustomCodec) Encode(connection gnet.Connection, packet gnet.Packet) []byte
这里直接返回原包的字节流数据 实际业务可以在此进行编码,如加密,压缩等
func (*CustomCodec) PacketHeaderSize ¶
func (this *CustomCodec) PacketHeaderSize() uint32
type CustomDataPacket ¶
type CustomDataPacket struct {
// contains filtered or unexported fields
}
包含一个消息号和[]byte的数据包
func NewCustomDataPacket ¶
func NewCustomDataPacket(command uint16, data []byte) *CustomDataPacket
func (*CustomDataPacket) Command ¶
func (this *CustomDataPacket) Command() gnet.PacketCommand
func (*CustomDataPacket) ErrorCode ¶
func (this *CustomDataPacket) ErrorCode() uint32
func (*CustomDataPacket) GetStreamData ¶
func (this *CustomDataPacket) GetStreamData() []byte
func (*CustomDataPacket) Message ¶
func (this *CustomDataPacket) Message() proto.Message
func (*CustomDataPacket) RpcCallId ¶
func (this *CustomDataPacket) RpcCallId() uint32
func (*CustomDataPacket) SetErrorCode ¶
func (this *CustomDataPacket) SetErrorCode(code uint32) *CustomDataPacket
func (*CustomDataPacket) SetRpcCallId ¶
func (this *CustomDataPacket) SetRpcCallId(rpcCallId uint32)
type CustomPacketHeader ¶
type CustomPacketHeader struct {
// contains filtered or unexported fields
}
自定义包头 implement of PacketHeader
func (*CustomPacketHeader) HasFlag ¶
func (this *CustomPacketHeader) HasFlag(flag uint8) bool
func (*CustomPacketHeader) Len ¶
func (this *CustomPacketHeader) Len() uint32
包体长度,不包含包头的长度 [0,0xFFFFFFFF]
func (*CustomPacketHeader) ReadFrom ¶
func (this *CustomPacketHeader) ReadFrom(packetHeaderData []byte)
从字节流读取数据,len(messageHeaderData)>=MessageHeaderSize 使用小端字节序
func (*CustomPacketHeader) WriteTo ¶
func (this *CustomPacketHeader) WriteTo(packetHeaderData []byte)
写入字节流,使用小端字节序
Click to show internal directories.
Click to hide internal directories.