Documentation ¶
Index ¶
Constants ¶
View Source
const ( UnknownType = iota OKType ErrType )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultPacker ¶
type DefaultPacker struct { // MaxDataSize represents the max size of `data` MaxDataSize int }
DefaultPacker is the default Packer used in session. Treats the packet with the format:
dataSize(4)|id(4)|data(n)
| segment | type | size | remark | | ---------- | ------ | ------- | ----------------------- | | `dataSize` | uint32 | 4 | the size of `data` only | | `id` | uint32 | 4 | | | `flag` | uint16 | 2 | | | `data` | []byte | dynamic | | .
func NewDefaultPacker ¶
func NewDefaultPacker() *DefaultPacker
NewDefaultPacker create a *DefaultPacker with initial field value.
type Packer ¶
type Packer interface { // Pack packs Message into the packet to be written. Pack(msg *message.Message) ([]byte, error) // Unpack unpacks the message packet from reader, // returns the Message, and error if error occurred. Unpack(reader io.Reader) (*message.Message, error) }
Packer is a generic interface to pack and unpack message packet.
Click to show internal directories.
Click to hide internal directories.