event

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteEvent

func DeleteEvent(event IEvent)

func SetEventPoolSize

func SetEventPoolSize(eventPoolSize int)

Types

type Event

type Event struct {
	Type      EventType
	Data      interface{}
	IntExt    [2]int64
	StringExt [2]string
	AnyExt    [2]any
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent() *Event

func (*Event) GetEventType

func (e *Event) GetEventType() EventType

func (*Event) IsRef

func (e *Event) IsRef() bool

func (*Event) Ref

func (e *Event) Ref()

func (*Event) Reset

func (e *Event) Reset()

func (*Event) UnRef

func (e *Event) UnRef()

type EventCallBack

type EventCallBack func(event IEvent)

EventCallBack 事件接受器

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 IEvent)

type EventProcessor

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

func (*EventProcessor) EventHandler

func (processor *EventProcessor) EventHandler(ev IEvent)

func (*EventProcessor) Init

func (processor *EventProcessor) Init(eventChannel IEventChannel)

func (*EventProcessor) RegEventReceiverFunc

func (processor *EventProcessor) RegEventReceiverFunc(eventType EventType, receiver IEventHandler, callback EventCallBack)

func (*EventProcessor) UnRegEventReceiverFun

func (processor *EventProcessor) UnRegEventReceiverFun(eventType EventType, receiver IEventHandler)

type EventType

type EventType int
const (
	ServiceRpcRequestEvent  EventType = -1
	ServiceRpcResponseEvent EventType = -2

	Sys_Event_Tcp             EventType = -3
	Sys_Event_Http_Event      EventType = -4
	Sys_Event_WebSocket       EventType = -5
	Sys_Event_Kcp             EventType = -6
	Sys_Event_Node_Conn_Event EventType = -7
	Sys_Event_Nats_Conn_Event EventType = -8
	Sys_Event_DiscoverService EventType = -9
	Sys_Event_Retire          EventType = -10
	Sys_Event_EtcdDiscovery   EventType = -11
	Sys_Event_Gin_Event       EventType = -12
	Sys_Event_FrameTick       EventType = -13

	Sys_Event_User_Define EventType = 1
)

大于Sys_Event_User_Define给用户定义

type IEvent

type IEvent interface {
	GetEventType() EventType
}

type IEventChannel

type IEventChannel interface {
	PushEvent(ev IEvent) error
}

type IEventHandler

type IEventHandler interface {
	Init(processor IEventProcessor)
	GetEventProcessor() IEventProcessor //获得事件
	NotifyEvent(IEvent)
	Destroy()
	// contains filtered or unexported methods
}

func NewEventHandler

func NewEventHandler() IEventHandler

type IEventProcessor

type IEventProcessor interface {
	IEventChannel

	Init(eventChannel IEventChannel)
	EventHandler(ev IEvent)
	RegEventReceiverFunc(eventType EventType, receiver IEventHandler, callback EventCallBack)
	UnRegEventReceiverFun(eventType EventType, receiver IEventHandler)
	// 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