v3

package
v0.0.0-...-83fd405 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PH                = 0
	SizeofMessageID   = 2
	SizeofMessageSeq  = 4
	SizeofMessageHead = SizeofMessageID + SizeofMessageSeq
)

Variables

View Source
var (
	ByteOrder = binary.LittleEndian // 小端
)

Functions

This section is empty.

Types

type IMessage

type IMessage interface {
	proto.Message
	V3()
	Head() MessageHead
	SetMessageSeq(seq MessageSeq)
	ResponseMessageID() MessageID
	Size() int
	MarshalTo([]byte) (int, error)
	Unmarshal([]byte) error
	ResetEx()
	Once() bool
	MinInterval() time.Duration
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type IMessageDispatcher

type IMessageDispatcher interface {
	Register(id MessageID, handler MessageHandler) (err error)
	Dispatch(iRecv IMessage, iSend IMessage, ctx actor.Context, args ...interface{}) (err error)
}

func NewMessageDispatcher

func NewMessageDispatcher() IMessageDispatcher

type IMessageFactoryManager

type IMessageFactoryManager interface {
	Register(messageID MessageID, iMsg IMessage, producer messageProducer, recycler messageRecycler, once bool, minInterval time.Duration)
	Produce(id MessageID) (IMessage, error)
	Recycle(iMsg IMessage) error
	ReflectType(id MessageID) reflect.Type
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewMessageFactoryManager

func NewMessageFactoryManager() IMessageFactoryManager

type IProtocol

type IProtocol interface {
	IMessageFactoryManager
	Alloc(size int) []byte
	Free(buffer []byte)
	Encrypt(data []byte) (err error)
	Decrypt(data []byte) (err error)
	EncodeTo(iMsg IMessage, data []byte) (err error)
	Encode(iMsg IMessage) (data []byte, err error)
	Decode(data []byte) (iMsg IMessage, err error)
}

func New

func New(allocator p.IAllocator, encryptor p.IEncryptor, decryptor p.IDecryptor) IProtocol

type MessageBroker

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

func NewMessageBroker

func NewMessageBroker() *MessageBroker

func (*MessageBroker) CanAccept

func (b *MessageBroker) CanAccept(iRecv IMessage) (err error)

type MessageHandler

type MessageHandler func(iRecv IMessage, iSend IMessage, ctx actor.Context, args ...interface{})

type MessageHead

type MessageHead struct {
	MessageID  MessageID
	MessageSeq MessageSeq
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type MessageID

type MessageID = uint16

type MessageSeq

type MessageSeq = uint32

Jump to

Keyboard shortcuts

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