message

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 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

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

type LuaDictionary

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

func NewLuaDictionary

func NewLuaDictionary(file string) *LuaDictionary

func (*LuaDictionary) IndexCode

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

func (*LuaDictionary) IndexRoute

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

func (*LuaDictionary) InitModule

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

func (*LuaDictionary) LoadLua

func (d *LuaDictionary) LoadLua(file string)

type MemberDictionary

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

func DuplicateDictionary

func DuplicateDictionary() *MemberDictionary

DuplicateDictionary returns dictionary for compressed route.

func NewMemberDictionary

func NewMemberDictionary() *MemberDictionary

func (*MemberDictionary) IndexCode

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

func (*MemberDictionary) IndexRoute

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.0.1

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

func (*Message) String

func (m *Message) String() string

String, implementation of fmt.Stringer interface

func (*Message) TypeValid

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