message

package
v0.0.0-...-9c04300 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(msg interface{}) (raw []byte, err error)
	Decode(raw []byte, msg interface{}) (err error)
}

func JsonCodec

func JsonCodec() Codec

type ID

type ID uint32

type Message

type Message struct {
	Meta   Meta        // 消息元数据
	Msg    interface{} // 消息体
	Raw    []byte      // 消息体流
	Stream []byte      // 消息流
}

type Meta

type Meta interface {
	ID() ID
	Name() string
	Codec() Codec
	Encode(msg interface{}) (raw []byte, err error)
	Decode(raw []byte) (msg interface{}, err error)
}

func Json

func Json(msg interface{}) (Meta, error)

func MetaByID

func MetaByID(id ID) (Meta, bool)

func MetaByMsg

func MetaByMsg(msg interface{}) (Meta, bool)

func MetaByName

func MetaByName(name string) (Meta, bool)

func MetaByType

func MetaByType(typo reflect.Type) (Meta, bool)

func Register

func Register(msg interface{}, codec Codec) (Meta, error)

func RegisterEx

func RegisterEx(id ID, name string, msg interface{}, codec Codec) (Meta, error)

Jump to

Keyboard shortcuts

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