Documentation ¶
Index ¶
- func BindProcessorHandler(peer cellnet.Peer, procName string, userCallback cellnet.EventCallback)
- func NewMultiHooker(h ...cellnet.EventHooker) cellnet.EventHooker
- func NewQueuedEventCallback(callback cellnet.EventCallback) cellnet.EventCallback
- func ProcessorList() (ret []string)
- func RegisterProcessor(procName string, f ProcessorBinder)
- type MessageDispatcher
- type MultiHooker
- type ProcessorBinder
- type ProcessorBundle
- type SyncReceiver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindProcessorHandler ¶
func BindProcessorHandler(peer cellnet.Peer, procName string, userCallback cellnet.EventCallback)
绑定固定回调处理器, procName来源于RegisterProcessor注册的处理器,形如: 'tcp.ltv'
func NewMultiHooker ¶
func NewMultiHooker(h ...cellnet.EventHooker) cellnet.EventHooker
func NewQueuedEventCallback ¶
func NewQueuedEventCallback(callback cellnet.EventCallback) cellnet.EventCallback
让EventCallback保证放在ses的队列里,而不是并发的
func RegisterProcessor ¶
func RegisterProcessor(procName string, f ProcessorBinder)
注册事件处理器,内部及自定义收发流程时使用
Types ¶
type MessageDispatcher ¶
type MessageDispatcher struct {
// contains filtered or unexported fields
}
消息派发器,可选件,兼容v3以前的注册及派发消息方式,在没有代码生成框架及工具时是较方便的接收处理接口
func NewMessageDispatcher ¶
func NewMessageDispatcher() *MessageDispatcher
func NewMessageDispatcherBindPeer ¶
func NewMessageDispatcherBindPeer(peer cellnet.Peer, processorName string) *MessageDispatcher
func (*MessageDispatcher) Exists ¶
func (self *MessageDispatcher) Exists(msgName string) bool
func (*MessageDispatcher) OnEvent ¶
func (self *MessageDispatcher) OnEvent(ev cellnet.Event)
func (*MessageDispatcher) RegisterMessage ¶
func (self *MessageDispatcher) RegisterMessage(msgName string, userCallback cellnet.EventCallback)
type MultiHooker ¶
type MultiHooker []cellnet.EventHooker
当需要多个Hooker时,使用NewMultiHooker将多个hooker合并成1个hooker处理
func (MultiHooker) OnInboundEvent ¶
func (self MultiHooker) OnInboundEvent(input cellnet.Event) (output cellnet.Event)
func (MultiHooker) OnOutboundEvent ¶
func (self MultiHooker) OnOutboundEvent(input cellnet.Event) (output cellnet.Event)
type ProcessorBinder ¶
type ProcessorBinder func(bundle ProcessorBundle, userCallback cellnet.EventCallback)
type ProcessorBundle ¶
type ProcessorBundle interface { // 设置 传输器,负责收发消息 SetTransmitter(v cellnet.MessageTransmitter) // 设置 接收后,发送前的事件处理流程 SetHooker(v cellnet.EventHooker) // 设置 接收后最终处理回调 SetCallback(v cellnet.EventCallback) }
处理器设置接口,由各Peer实现
type SyncReceiver ¶
type SyncReceiver struct {
// contains filtered or unexported fields
}
同步接收消息器, 可选件,可作为流程测试辅助工具
func NewSyncReceiver ¶
func NewSyncReceiver(p cellnet.Peer) *SyncReceiver
func (*SyncReceiver) EventCallback ¶
func (self *SyncReceiver) EventCallback() cellnet.EventCallback
将处理回调返回给BindProcessorHandler用于注册
func (*SyncReceiver) Recv ¶
func (self *SyncReceiver) Recv(callback cellnet.EventCallback) *SyncReceiver
持续阻塞,直到某个消息到达后,使用回调返回消息
func (*SyncReceiver) WaitMessage ¶
func (self *SyncReceiver) WaitMessage(msgName string) (msg interface{})
持续阻塞,直到某个消息到达后,返回消息
Click to show internal directories.
Click to hide internal directories.