event

package
v0.0.0-...-ff803ae Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultEventChannelLen = 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) Destroy

func (handler *EventHandler) Destroy()

func (*EventHandler) GetEventProcessor

func (handler *EventHandler) GetEventProcessor() IEventProcessor

func (*EventHandler) Init

func (handler *EventHandler) Init(processor IEventProcessor)

func (*EventHandler) NotifyEvent

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

type EventProcessor

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

func (*EventProcessor) EventHandler

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

func (*EventProcessor) GetEventChan

func (processor *EventProcessor) GetEventChan() chan Event

func (*EventProcessor) RegEventReciverFunc

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

func (*EventProcessor) SetEventChannel

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

func (*EventProcessor) UnRegEventReciverFun

func (processor *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 {
	Init(processor IEventProcessor)
	GetEventProcessor() IEventProcessor //获得事件
	NotifyEvent(*Event)
	Destroy()
	// contains filtered or unexported methods
}

func NewEventHandler

func NewEventHandler() IEventHandler

type IEventProcessor

type IEventProcessor interface {
	EventHandler(ev *Event)
	//同一个IEventHandler,只能接受一个EventType类型回调
	RegEventReciverFunc(eventType EventType, reciver IEventHandler, callback EventCallBack)
	UnRegEventReciverFun(eventType EventType, reciver IEventHandler)
	SetEventChannel(channelNum int) bool

	GetEventChan() chan Event
	// contains filtered or unexported methods
}

func NewEventProcessor

func NewEventProcessor() IEventProcessor

Jump to

Keyboard shortcuts

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