feat: 优化 game.Player 的 Send 和 Close 函数与 server.Conn 同步
This commit is contained in:
parent
039500ba87
commit
f65a1555f6
|
@ -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...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue