proto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MulanPSL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtoIDHeartbeatReq = uint32(1)
	ProtoIDHeartbeatRsp = uint32(2)
	ProtoIDEchoReq      = uint32(3)
	ProtoIDEchoRsp      = uint32(4)
)

Variables

View Source
var DefaultMessageProtocol = &MessageProtocol{}

Functions

func Encode

func Encode(msg Message) ([]byte, error)

func RegMessageDef

func RegMessageDef(def Message)

Types

type DefineST

type DefineST interface {
	Name() string
	NewST() DefineST

	Encode() ([]byte, error)
	Decode([]byte) error

	String() string
}

type EchoReq

type EchoReq struct {
	Echo   string     `json:"echo,omitempty"`
	Header *HeaderReq `json:"header"`
}

func NewEchoReq

func NewEchoReq() *EchoReq

func (*EchoReq) Decode

func (st *EchoReq) Decode(bs []byte) error

func (*EchoReq) Encode

func (st *EchoReq) Encode() ([]byte, error)

func (*EchoReq) Name

func (st *EchoReq) Name() string

func (*EchoReq) New

func (st *EchoReq) New() Message

func (*EchoReq) NewST

func (st *EchoReq) NewST() DefineST

func (*EchoReq) ProtoID

func (st *EchoReq) ProtoID() uint32

func (*EchoReq) String

func (st *EchoReq) String() string

type EchoRsp

type EchoRsp struct {
	Echo   string     `json:"echo,omitempty"`
	Header *HeaderRsp `json:"header"`
}

func NewEchoRsp

func NewEchoRsp() *EchoRsp

func (*EchoRsp) Decode

func (st *EchoRsp) Decode(bs []byte) error

func (*EchoRsp) Encode

func (st *EchoRsp) Encode() ([]byte, error)

func (*EchoRsp) Name

func (st *EchoRsp) Name() string

func (*EchoRsp) New

func (st *EchoRsp) New() Message

func (*EchoRsp) NewST

func (st *EchoRsp) NewST() DefineST

func (*EchoRsp) ProtoID

func (st *EchoRsp) ProtoID() uint32

func (*EchoRsp) String

func (st *EchoRsp) String() string

type HeaderReq

type HeaderReq struct {
	Seq int64 `json:"seq,omitempty"`
	Ts  int64 `json:"ts,omitempty"`
}

func NewHeaderReq

func NewHeaderReq() *HeaderReq

func (*HeaderReq) Decode

func (st *HeaderReq) Decode(bs []byte) error

func (*HeaderReq) Encode

func (st *HeaderReq) Encode() ([]byte, error)

func (*HeaderReq) Name

func (st *HeaderReq) Name() string

func (*HeaderReq) NewST

func (st *HeaderReq) NewST() DefineST

func (*HeaderReq) String

func (st *HeaderReq) String() string

type HeaderRsp

type HeaderRsp struct {
	ErrCode    uint32 `json:"err_code,omitempty"`
	ErrMessage string `json:"err_message,omitempty"`
	Seq        int64  `json:"seq,omitempty"`
	Ts         int64  `json:"ts,omitempty"`
}

func NewHeaderRsp

func NewHeaderRsp() *HeaderRsp

func (*HeaderRsp) Decode

func (st *HeaderRsp) Decode(bs []byte) error

func (*HeaderRsp) Encode

func (st *HeaderRsp) Encode() ([]byte, error)

func (*HeaderRsp) Name

func (st *HeaderRsp) Name() string

func (*HeaderRsp) NewST

func (st *HeaderRsp) NewST() DefineST

func (*HeaderRsp) String

func (st *HeaderRsp) String() string

type HeartbeatReq

type HeartbeatReq struct {
	Header *HeaderReq `json:"header"`
}

func NewHeartbeatReq

func NewHeartbeatReq() *HeartbeatReq

func (*HeartbeatReq) Decode

func (st *HeartbeatReq) Decode(bs []byte) error

func (*HeartbeatReq) Encode

func (st *HeartbeatReq) Encode() ([]byte, error)

func (*HeartbeatReq) Name

func (st *HeartbeatReq) Name() string

func (*HeartbeatReq) New

func (st *HeartbeatReq) New() Message

func (*HeartbeatReq) NewST

func (st *HeartbeatReq) NewST() DefineST

func (*HeartbeatReq) ProtoID

func (st *HeartbeatReq) ProtoID() uint32

func (*HeartbeatReq) String

func (st *HeartbeatReq) String() string

type HeartbeatRsp

type HeartbeatRsp struct {
	Header *HeaderRsp `json:"header"`
}

func NewHeartbeatRsp

func NewHeartbeatRsp() *HeartbeatRsp

func (*HeartbeatRsp) Decode

func (st *HeartbeatRsp) Decode(bs []byte) error

func (*HeartbeatRsp) Encode

func (st *HeartbeatRsp) Encode() ([]byte, error)

func (*HeartbeatRsp) Name

func (st *HeartbeatRsp) Name() string

func (*HeartbeatRsp) New

func (st *HeartbeatRsp) New() Message

func (*HeartbeatRsp) NewST

func (st *HeartbeatRsp) NewST() DefineST

func (*HeartbeatRsp) ProtoID

func (st *HeartbeatRsp) ProtoID() uint32

func (*HeartbeatRsp) String

func (st *HeartbeatRsp) String() string

type Message

type Message interface {
	DefineST

	ProtoID() uint32
	New() Message
}

func Decode

func Decode(id uint32, bs []byte) (Message, error)

func New

func New(id uint32) Message

type MessageProtocol

type MessageProtocol struct {
}

func (*MessageProtocol) Decode

func (h *MessageProtocol) Decode(id uint32, bs []byte) (server.Message, error)

func (*MessageProtocol) Encode

func (h *MessageProtocol) Encode(msg server.Message) ([]byte, error)

func (*MessageProtocol) New

func (h *MessageProtocol) New(id uint32) server.Message

Jump to

Keyboard shortcuts

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