Documentation ¶
Index ¶
- Constants
- Variables
- type IMessage
- type IMessageDispatcher
- type IMessageFactoryManager
- type IProtocol
- type MessageDispatcher
- func (md *MessageDispatcher) Dispatch(iMsg IMessage, args ...interface{}) error
- func (md *MessageDispatcher) Register(id MessageID, handler MessageHandler)
- func (md *MessageDispatcher) RegisterWithLimit(id MessageID, handler MessageHandler, minDispatchInterval time.Duration)
- func (md *MessageDispatcher) SetLimit(id MessageID, minInterval time.Duration) error
- type MessageHandler
- type MessageID
- type OneMessageDispatcher
Constants ¶
View Source
const ( PH = 0 SizeofMessageID = 2 )
View Source
const DefaultMinDispatchInterval = 100 * time.Millisecond
Variables ¶
View Source
var (
ByteOrder = binary.LittleEndian // 小端
)
Functions ¶
This section is empty.
Types ¶
type IMessageDispatcher ¶
type IMessageDispatcher interface { Register(id MessageID, handler MessageHandler) RegisterWithLimit(id MessageID, handler MessageHandler, minDispatchInterval time.Duration) Dispatch(iMsg IMessage, args ...interface{}) error SetLimit(id MessageID, minInterval time.Duration) error }
func NewMessageDispatcher ¶
func NewMessageDispatcher() IMessageDispatcher
type IMessageFactoryManager ¶
type IMessageFactoryManager interface { Register(iMsg IMessage, producer messageProducer, recycler messageRecycler) 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) (IMessage, error) }
func New ¶
func New(allocator p.IAllocator, encryptor p.IEncryptor, decryptor p.IDecryptor) IProtocol
type MessageDispatcher ¶
type MessageDispatcher struct {
Dispatchers map[MessageID]*OneMessageDispatcher
}
func (*MessageDispatcher) Dispatch ¶
func (md *MessageDispatcher) Dispatch(iMsg IMessage, args ...interface{}) error
func (*MessageDispatcher) Register ¶
func (md *MessageDispatcher) Register(id MessageID, handler MessageHandler)
func (*MessageDispatcher) RegisterWithLimit ¶
func (md *MessageDispatcher) RegisterWithLimit(id MessageID, handler MessageHandler, minDispatchInterval time.Duration)
type MessageHandler ¶
type MessageHandler func(IMessage, ...interface{})
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type OneMessageDispatcher ¶
type OneMessageDispatcher struct { Handlers []MessageHandler MinDispatchInterval time.Duration LastDispatchTime time.Time }
Click to show internal directories.
Click to hide internal directories.