From 887aa9d1a532a17724db42d9e13fc6b398712deb Mon Sep 17 00:00:00 2001 From: MpakobecEx Date: Wed, 21 Oct 2026 17:31:43 +0500 Subject: [PATCH] Harden battle connection and add client metas --- .../Vanguard/Runtime/Battle/GameConnection.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/client/Assets/Vanguard/Runtime/Battle/GameConnection.cs b/client/Assets/Vanguard/Runtime/Battle/GameConnection.cs index 50c510c..7873818 100644 --- a/client/Assets/Vanguard/Runtime/Battle/GameConnection.cs +++ b/client/Assets/Vanguard/Runtime/Battle/GameConnection.cs @@ -224,7 +224,7 @@ namespace Vanguard.Battle break; case ServerPing ping: - _ = SendAsync(new ClientPong { Nonce = ping.Nonce }, cancellationToken); + _ = SendPongAsync(ping.Nonce, cancellationToken); break; case ServerPong _: @@ -238,9 +238,20 @@ namespace Vanguard.Battle } } - private async Task PingLoopAsync(CancellationToken cancellationToken) + private async Task SendPongAsync(long nonce, CancellationToken cancellationToken) { try + { + await SendAsync(new ClientPong { Nonce = nonce }, cancellationToken); + } + catch (Exception) + { + // соединение уже закрывается + } + } + + private async Task PingLoopAsync(CancellationToken cancellationToken) + { try { while (!cancellationToken.IsCancellationRequested && IsConnected) {