feat: 优化 game.Player 的 Send 和 Close 函数与 server.Conn 同步

This commit is contained in:
kercylan98 2023-10-11 14:44:58 +08:00
parent 039500ba87
commit f65a1555f6
2 changed files with 5 additions and 5 deletions

View File

@ -34,11 +34,11 @@ func (slf *Player[ID]) UseConn(conn *server.Conn) {
} }
// Send 向该玩家发送数据 // Send 向该玩家发送数据
func (slf *Player[ID]) Send(packet []byte) { func (slf *Player[ID]) Send(packet []byte, callback ...func(err error)) {
slf.conn.Write(packet) slf.conn.Write(packet, callback...)
} }
// Close 关闭玩家 // Close 关闭玩家
func (slf *Player[ID]) Close() { func (slf *Player[ID]) Close(err ...error) {
slf.conn.Close() slf.conn.Close(err...)
} }

View File

@ -11,5 +11,5 @@ type Player[ID comparable] interface {
// UseConn 指定连接 // UseConn 指定连接
UseConn(conn *server.Conn) UseConn(conn *server.Conn)
// Close 关闭玩家并且释放其资源 // Close 关闭玩家并且释放其资源
Close() Close(err ...error)
} }