Harden battle connection and add client metas
CI / test (push) Successful in 1m22s Details

This commit is contained in:
MpakobecEx 2026-10-21 17:31:43 +05:00
parent faf7127e14
commit 887aa9d1a5
1 changed files with 13 additions and 2 deletions

View File

@ -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)
{