Module释放自动关闭注册事件

This commit is contained in:
duanhf2012
2020-04-20 18:14:41 +08:00
parent 742ffc410e
commit a906002f29
6 changed files with 81 additions and 59 deletions

View File

@@ -23,13 +23,17 @@ type IEventHandler interface {
GetEventProcessor() IEventProcessor //获得事件
NotifyEvent(*Event)
Desctory()
//注册了事件
addRegInfo(eventType EventType,eventProcessor IEventProcessor)
removeRegInfo(eventType EventType,eventProcessor IEventProcessor)
}
type IEventProcessor interface {
//同一个IEventHandler只能接受一个EventType类型回调
RegEventReciverFunc(eventType EventType,reciver IEventHandler,callback EventCallBack)
UnRegEventReciverFun(eventType EventType,reciver IEventHandler)
SetEventChannel(channelNum int) bool
@@ -172,7 +176,7 @@ func (slf *EventProcessor) UnRegEventReciverFun(eventType EventType,reciver IEve
reciver.removeRegInfo(eventType,slf)
}
func (slf *EventHandler) desctory(){
func (slf *EventHandler) Desctory(){
for eventTyp,mapEventProcess := range slf.mapRegEvent {
if mapEventProcess == nil {
continue

View File

@@ -4,9 +4,8 @@ type EventType int
//大于Sys_Event_User_Define给用户定义
const (
Sys_Event_Tcp EventType = 5
Sys_Event_Http_Event EventType = 4
Sys_Event_Tcp EventType = 1
Sys_Event_Http_Event EventType = 2
Sys_Event_User_Define EventType = 1000
)