package event import "git.noahlan.cn/noahlan/nnet/connection" type ( ConnFn func(conn *connection.Connection) ErrFn func(err error) // ConnEvents 连接事件 ConnEvents interface { // OnConnected 连接成功回调 OnConnected(h ConnFn) // OnConnectError 连接异常回调, 在准备进行连接的过程中发生异常时触发 OnConnectError(err error) // OnDisconnected 连接断开回调,网络异常,服务端掉线等情况时触发 OnDisconnected(conn *connection.Connection, err error) // OnClose 连接关闭回调,服务端发起关闭信号或客户端主动关闭时触发 OnClose(details any, err error) } // MessageEvents 消息事件 MessageEvents interface { // OnSentError 发送消息异常回调 OnSentError(details any, err error) // OnReceiveError 接收消息异常回调 OnReceiveError(details any, err error) } ) type Manager struct { ConnEvents MessageEvents onConnected []OnConnectedFn } func NewEventManager() *Manager { return &Manager{} }