event

package
v0.0.0-...-604ee51 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Default_EventChannelLen = 10000

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type EventType
	Data interface{}
}

type EventCallBack

type EventCallBack func(event *Event)

事件接受器

type EventHandler

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

func (*EventHandler) Desctory

func (slf *EventHandler) Desctory()

func (*EventHandler) GetEventProcessor

func (slf *EventHandler) GetEventProcessor() IEventProcessor

func (*EventHandler) Init

func (slf *EventHandler) Init(processor IEventProcessor)

func (*EventHandler) NotifyEvent

func (slf *EventHandler) NotifyEvent(ev *Event)

type EventProcessor

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

func (*EventProcessor) EventHandler

func (slf *EventProcessor) EventHandler(ev *Event)

func (*EventProcessor) GetEventChan

func (slf *EventProcessor) GetEventChan() chan *Event

func (*EventProcessor) RegEventReciverFunc

func (slf *EventProcessor) RegEventReciverFunc(eventType EventType, reciver IEventHandler, callback EventCallBack)

func (*EventProcessor) SetEventChannel

func (slf *EventProcessor) SetEventChannel(channelNum int) bool

func (*EventProcessor) UnRegEventReciverFun

func (slf *EventProcessor) UnRegEventReciverFun(eventType EventType, reciver IEventHandler)

type EventType

type EventType int
const (
	Sys_Event_Tcp         EventType = 1
	Sys_Event_Http_Event  EventType = 2
	Sys_Event_WebSocket   EventType = 3
	Sys_Event_User_Define EventType = 1000
)

大于Sys_Event_User_Define给用户定义

type IEventHandler

type IEventHandler interface {
	GetEventProcessor() IEventProcessor //获得事件
	NotifyEvent(*Event)

	Desctory()
	// contains filtered or unexported methods
}

type IEventProcessor

type IEventProcessor interface {
	//同一个IEventHandler,只能接受一个EventType类型回调
	RegEventReciverFunc(eventType EventType, reciver IEventHandler, callback EventCallBack)
	UnRegEventReciverFun(eventType EventType, reciver IEventHandler)
	SetEventChannel(channelNum int) bool
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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