sample_proto

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ProtoIDMin          = uint32(0) //Invalid ID
	ProtoIDHeartbeatReq = uint32(1)
	ProtoIDHeartbeatRsp = uint32(2)
	ProtoIDEchoReq      = uint32(5)
	ProtoIDEchoRsp      = uint32(6)
	ProtoIDSubAReq      = uint32(30001)
	ProtoIDSubARsp      = uint32(30002)
	ProtoIDSubBReq      = uint32(30003)
	ProtoIDSubBRsp      = uint32(30004)
)

ProtoID

View Source
const (
	ErrCodeOK   = uint32(0)
	ErrCodeFail = uint32(1)
)

ErrorCode

Variables

This section is empty.

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 added in v0.3.0

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

func NewEchoReq added in v0.3.0

func NewEchoReq() *EchoReq

func (*EchoReq) Decode added in v0.3.0

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

func (*EchoReq) Encode added in v0.3.0

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

func (*EchoReq) Name added in v0.3.0

func (st *EchoReq) Name() string

func (*EchoReq) New added in v0.3.0

func (st *EchoReq) New() Message

func (*EchoReq) NewST added in v0.3.0

func (st *EchoReq) NewST() DefineST

func (*EchoReq) ProtoID added in v0.3.0

func (st *EchoReq) ProtoID() uint32

func (*EchoReq) String added in v0.3.0

func (st *EchoReq) String() string

type EchoRsp added in v0.3.0

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

func NewEchoRsp added in v0.3.0

func NewEchoRsp() *EchoRsp

func (*EchoRsp) Decode added in v0.3.0

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

func (*EchoRsp) Encode added in v0.3.0

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

func (*EchoRsp) Name added in v0.3.0

func (st *EchoRsp) Name() string

func (*EchoRsp) New added in v0.3.0

func (st *EchoRsp) New() Message

func (*EchoRsp) NewST added in v0.3.0

func (st *EchoRsp) NewST() DefineST

func (*EchoRsp) ProtoID added in v0.3.0

func (st *EchoRsp) ProtoID() uint32

func (*EchoRsp) String added in v0.3.0

func (st *EchoRsp) String() string

type HeaderReq

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

request header

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 {
	//Multi doc string
	//IDArr
	ArrI       []int32           `json:"arr_i,omitempty"`
	ArrT       []*SubST          `json:"arr_t,omitempty"`
	B1         bool              `json:"b_1,omitempty"`
	ErrCode    uint32            `json:"err_code,omitempty"`
	ErrMessage string            `json:"err_message,omitempty"` //maybe more detail than ErrCode
	F1         float64           `json:"f_1,omitempty"`
	MapSS      map[string]string `json:"map_ss,omitempty"`
	Seq        int32             `json:"seq,omitempty"`
	St         *SubST            `json:"st,omitempty"`
	Text       []byte            `json:"text,omitempty"`
	Ts         int64             `json:"ts,omitempty"` //timestamp millisecond
}

response header

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 {
	Echo   string     `json:"echo,omitempty"`
	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 {
	Echo   string     `json:"echo,omitempty"`
	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 SubAElem

type SubAElem struct {
	IDList []string `json:"id_list,omitempty"`
	Lang   string   `json:"lang,omitempty"`
}

func NewSubAElem

func NewSubAElem() *SubAElem

func (*SubAElem) Decode

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

func (*SubAElem) Encode

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

func (*SubAElem) Name

func (st *SubAElem) Name() string

func (*SubAElem) NewST

func (st *SubAElem) NewST() DefineST

func (*SubAElem) String

func (st *SubAElem) String() string

type SubAReq

type SubAReq struct {
	Header *HeaderReq  `json:"header"`
	List   []*SubAElem `json:"list,omitempty"`
}

func NewSubAReq

func NewSubAReq() *SubAReq

func (*SubAReq) Decode

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

func (*SubAReq) Encode

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

func (*SubAReq) Name

func (st *SubAReq) Name() string

func (*SubAReq) New

func (st *SubAReq) New() Message

func (*SubAReq) NewST

func (st *SubAReq) NewST() DefineST

func (*SubAReq) ProtoID

func (st *SubAReq) ProtoID() uint32

func (*SubAReq) String

func (st *SubAReq) String() string

type SubARsp

type SubARsp struct {
	Header   *HeaderRsp               `json:"header"`
	Modified []string                 `json:"modified,omitempty"`
	Reward   []*super_schema.ItemElem `json:"reward,omitempty"`
}

func NewSubARsp

func NewSubARsp() *SubARsp

func (*SubARsp) Decode

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

func (*SubARsp) Encode

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

func (*SubARsp) Name

func (st *SubARsp) Name() string

func (*SubARsp) New

func (st *SubARsp) New() Message

func (*SubARsp) NewST

func (st *SubARsp) NewST() DefineST

func (*SubARsp) ProtoID

func (st *SubARsp) ProtoID() uint32

func (*SubARsp) String

func (st *SubARsp) String() string

type SubBReq

type SubBReq struct {
	Header *HeaderReq  `json:"header"`
	List   []*SubAElem `json:"list,omitempty"`
}

func NewSubBReq

func NewSubBReq() *SubBReq

func (*SubBReq) Decode

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

func (*SubBReq) Encode

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

func (*SubBReq) Name

func (st *SubBReq) Name() string

func (*SubBReq) New

func (st *SubBReq) New() Message

func (*SubBReq) NewST

func (st *SubBReq) NewST() DefineST

func (*SubBReq) ProtoID

func (st *SubBReq) ProtoID() uint32

func (*SubBReq) String

func (st *SubBReq) String() string

type SubBRsp

type SubBRsp struct {
	Header   *HeaderRsp `json:"header"`
	Modified []string   `json:"modified,omitempty"`
}

func NewSubBRsp

func NewSubBRsp() *SubBRsp

func (*SubBRsp) Decode

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

func (*SubBRsp) Encode

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

func (*SubBRsp) Name

func (st *SubBRsp) Name() string

func (*SubBRsp) New

func (st *SubBRsp) New() Message

func (*SubBRsp) NewST

func (st *SubBRsp) NewST() DefineST

func (*SubBRsp) ProtoID

func (st *SubBRsp) ProtoID() uint32

func (*SubBRsp) String

func (st *SubBRsp) String() string

type SubST

type SubST struct {
	Sub string `json:"sub,omitempty"`
}

func NewSubST

func NewSubST() *SubST

func (*SubST) Decode

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

func (*SubST) Encode

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

func (*SubST) Name

func (st *SubST) Name() string

func (*SubST) NewST

func (st *SubST) NewST() DefineST

func (*SubST) String

func (st *SubST) String() string

Jump to

Keyboard shortcuts

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