From ec341ecaaa5354fe4d0d3ebd23881d19cbb1f8b1 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Fri, 5 May 2023 17:01:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/event.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/event.go b/server/event.go index 81d2791..da78505 100644 --- a/server/event.go +++ b/server/event.go @@ -9,9 +9,9 @@ import ( type StartBeforeEventHandle func(srv *Server) type StartFinishEventHandle func(srv *Server) -type ConnectionReceivePacketEventHandle func(conn *Conn, packet []byte) -type ConnectionOpenedEventHandle func(conn *Conn) -type ConnectionClosedEventHandle func(conn *Conn) +type ConnectionReceivePacketEventHandle func(srv *Server, conn *Conn, packet []byte) +type ConnectionOpenedEventHandle func(srv *Server, conn *Conn) +type ConnectionClosedEventHandle func(srv *Server, conn *Conn) type event struct { *Server @@ -59,7 +59,7 @@ func (slf *event) OnConnectionClosedEvent(conn *Conn) { log.Debug("Server", zap.String("ConnectionClosed", conn.GetID())) slf.Server.connections.Delete(conn.ip) for _, handle := range slf.connectionClosedEventHandles { - handle(conn) + handle(slf.Server, conn) } } @@ -76,7 +76,7 @@ func (slf *event) OnConnectionOpenedEvent(conn *Conn) { log.Debug("Server", zap.String("ConnectionOpened", conn.GetID())) slf.Server.connections.Set(conn.ip, conn) for _, handle := range slf.connectionOpenedEventHandles { - handle(conn) + handle(slf.Server, conn) } } @@ -91,7 +91,7 @@ func (slf *event) RegConnectionReceivePacketEvent(handle ConnectionReceivePacket func (slf *event) OnConnectionReceivePacketEvent(conn *Conn, packet []byte) { for _, handle := range slf.connectionReceivePacketEventHandles { - handle(conn, packet) + handle(slf.Server, conn, packet) } }