Documentation ¶
Index ¶
Constants ¶
View Source
const ( EvtOnConnected = "OnConnected" EvtOnConnectError = "OnConnectError" EvtOnDisconnected = "OnDisconnected" EvtOnClose = "OnClose" EvtOnSend = "OnSend" EvtOnSendError = "OnSendError" EvtOnReceive = "OnReceive" EvtOnReceiveError = "OnReceiveError" )
Variables ¶
View Source
var ErrEventTypeIllegal = errors.New("EventType illegal")
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { // OnConnected 连接成功回调 OnConnected(nc *conn.Connection) // OnConnectError 连接异常回调, 在准备进行连接的过程中发生异常时触发 OnConnectError(err error) // OnDisconnected 连接断开回调,网络异常,服务端掉线等情况时触发 OnDisconnected(nc *conn.Connection, err error) // OnClose 连接关闭回调,服务端发起关闭信号或客户端主动关闭时触发 OnClose(nc *conn.Connection) // OnSend 消息发送回调,消息序列化后的回调 OnSend(nc *conn.Connection, v any) // OnSendError 发送消息异常回调 OnSendError(nc *conn.Connection, v any, err error) // OnReceive 消息接收回调,消息解包后的回调 OnReceive(nc *conn.Connection, p packet.IPacket) // OnReceiveError 接收消息异常回调 OnReceiveError(nc *conn.Connection, err error) }
type EventManager ¶
type EventManager interface { Event // RegisterEventFront 向头部注册事件处理器 RegisterEventFront(evtType EvtType, fn any) // RegisterEvent 注册事件处理器 RegisterEvent(evtType EvtType, fn any) }
func NewEventManager ¶
func NewEventManager() EventManager
type OnCloseFn ¶
type OnCloseFn func(conn *conn.Connection)
type OnConnectErrorFn ¶
type OnConnectErrorFn func(err error)
type OnConnectedFn ¶
type OnConnectedFn func(nc *conn.Connection)
type OnDisconnectedFn ¶
type OnDisconnectedFn func(nc *conn.Connection, err error)
type OnReceiveErrorFn ¶
type OnReceiveErrorFn func(nc *conn.Connection, err error)
type OnReceiveFn ¶
type OnReceiveFn func(nc *conn.Connection, p packet.IPacket)
type OnSendErrorFn ¶
type OnSendErrorFn func(nc *conn.Connection, v any, err error)
type OnSendFn ¶
type OnSendFn func(nc *conn.Connection, v any)
Click to show internal directories.
Click to hide internal directories.