From f65a1555f64f55650b1aac52e00d3f1759c5b97b Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Wed, 11 Oct 2023 14:44:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20game.Player=20?= =?UTF-8?q?=E7=9A=84=20Send=20=E5=92=8C=20Close=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=B8=8E=20server.Conn=20=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/builtin/player.go | 8 ++++---- game/player.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/game/builtin/player.go b/game/builtin/player.go index 876178a..5013174 100644 --- a/game/builtin/player.go +++ b/game/builtin/player.go @@ -34,11 +34,11 @@ func (slf *Player[ID]) UseConn(conn *server.Conn) { } // Send 向该玩家发送数据 -func (slf *Player[ID]) Send(packet []byte) { - slf.conn.Write(packet) +func (slf *Player[ID]) Send(packet []byte, callback ...func(err error)) { + slf.conn.Write(packet, callback...) } // Close 关闭玩家 -func (slf *Player[ID]) Close() { - slf.conn.Close() +func (slf *Player[ID]) Close(err ...error) { + slf.conn.Close(err...) } diff --git a/game/player.go b/game/player.go index f322136..b069374 100644 --- a/game/player.go +++ b/game/player.go @@ -11,5 +11,5 @@ type Player[ID comparable] interface { // UseConn 指定连接 UseConn(conn *server.Conn) // Close 关闭玩家并且释放其资源 - Close() + Close(err ...error) }