message

package
v1.1.105 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyDictionary = NewMemberDictionary()
)
View Source
var ErrIndexCodeNotFound = errors.New("dictionary: index code not found")
View Source
var ErrIndexRouteNotFound = errors.New("dictionary: index route not found")

Functions

func ShortVersion

func ShortVersion(version string) uint32

func WriteDictionary

func WriteDictionary(items []*clusterpb.DictionaryItem)

WriteDictionary is to set dictionary when new route dictionary is found.

func WriteDictionaryItem

func WriteDictionaryItem(route string, code uint32)

WriteDictionaryItem is to set dictionary item when server registers.

Types

type Dictionary added in v1.0.1

type Dictionary interface {
	IndexRoute(string) (uint32, error)
	IndexCode(uint32) (string, error)
}

type LuaDictionary added in v1.0.1

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

func NewLuaDictionary added in v1.0.1

func NewLuaDictionary(file string) *LuaDictionary

func (*LuaDictionary) IndexCode added in v1.0.1

func (d *LuaDictionary) IndexCode(code uint32) (string, error)

func (*LuaDictionary) IndexRoute added in v1.0.1

func (d *LuaDictionary) IndexRoute(route string) (uint32, error)

func (*LuaDictionary) InitModule added in v1.0.1

func (d *LuaDictionary) InitModule(l *lua.LState) int

func (*LuaDictionary) LoadLua added in v1.0.1

func (d *LuaDictionary) LoadLua(file string)

type MemberDictionary added in v1.0.1

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

func DuplicateDictionary added in v1.0.1

func DuplicateDictionary() *MemberDictionary

DuplicateDictionary returns dictionary for compressed route.

func NewMemberDictionary added in v1.0.1

func NewMemberDictionary() *MemberDictionary

func (*MemberDictionary) IndexCode added in v1.0.1

func (d *MemberDictionary) IndexCode(code uint32) (string, error)

func (*MemberDictionary) IndexRoute added in v1.0.1

func (d *MemberDictionary) IndexRoute(route string) (uint32, error)

type Message

type Message struct {
	Type      Type   // message type
	Branch    uint32 // client branch
	ShortVer  uint32 // message short version
	ID        uint64 // unique id, zero while notify mode
	UnixTime  uint32 // unix time in seconds
	SessionID uint64 // server session id int64
	Route     string // route for locating service
	DataType  uint32 // data type
	Data      []byte // payload
}

Message represents a unmarshaled message or a message which to be marshaled

func New

func New() *Message

New returns a new message instance

func (*Message) Serializer added in v1.1.37

func (m *Message) Serializer() serializer.Serializer

func (*Message) String

func (m *Message) String() string

String, implementation of fmt.Stringer interface

func (*Message) TypeValid added in v1.0.1

func (m *Message) TypeValid() bool

type Type

type Type byte

Type represents the type of message, which could be Request/Notify/Response/Push

const (
	Request Type = iota
	Notify
	Response
	Push
)

Message types

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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