Harden battle connection and add client metas
CI / test (push) Successful in 1m22s
Details
CI / test (push) Successful in 1m22s
Details
This commit is contained in:
parent
faf7127e14
commit
887aa9d1a5
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue