codec

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

协议内容编码

协议内容编码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 客户端消息

func NewBinClient

func NewBinClient(bin binary.ByteOrder, mix ...uint8) *Client

func NewClient

func NewClient(mix ...uint8) *Client

func (*Client) HeadLen

func (c *Client) HeadLen() int

func (*Client) Marshal

func (c *Client) Marshal(head *ClientHead, data []byte) (b []byte, err error)

Marshal 编码消息

func (*Client) SetByteOrder

func (c *Client) SetByteOrder(bin binary.ByteOrder)

设置大小端

func (*Client) SetMix

func (c *Client) SetMix(mix ...uint8)

设置混淆 (最长4位)

func (*Client) Unmarshal

func (c *Client) Unmarshal(raw []byte) (head *ClientHead, data []byte, err error)

Unmarshal 解码消息

type ClientHead

type ClientHead struct {
	Serial  uint16
	Cmd     uint32
	DataLen uint32
}

ClientHead 客户端消息头

type Server

type Server struct {
	// contains filtered or unexported fields
}

Client 服务端消息

func NewBinServer

func NewBinServer(bin binary.ByteOrder, mix ...uint8) *Server

func NewServer

func NewServer(mix ...uint8) *Server

func (*Server) HeadLen

func (c *Server) HeadLen() int

func (*Server) Marshal

func (c *Server) Marshal(head *ServerHead, data []byte) (b []byte, err error)

Marshal 编码消息

func (*Server) SetByteOrder

func (c *Server) SetByteOrder(bin binary.ByteOrder)

设置大小端

func (*Server) SetMix

func (c *Server) SetMix(mix ...uint8)

设置混淆 (最长4位)

func (*Server) Unmarshal

func (c *Server) Unmarshal(raw []byte) (head *ServerHead, data []byte, err error)

Unmarshal 解码消息

type ServerHead

type ServerHead struct {
	Serial  uint16
	Cmd     uint32
	Code    uint32
	DataLen uint32
}

ServerHead 服务器消息头

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL