Add adaptive packet loss handling
Build and test / test (macos-latest) (push) Canceled after 0s
Build and test / test (ubuntu-24.04) (push) Canceled after 0s
Build and test / test (windows-latest) (push) Canceled after 0s
Build and test / apple-client (push) Canceled after 0s

This commit is contained in:
2026-09-22 16:54:49 +02:00
parent 7c4708c3de
commit 7b0c003ad4
35 changed files with 518 additions and 60 deletions
+12 -3
View File
@@ -5,6 +5,7 @@ using System.Net.Sockets;
using VoiceCat.Crypto;
using VoiceCat.Server;
using VoiceCat.Server.Transport;
using VoiceCat.Protocol;
using Voicecat.V1;
namespace VoiceCat.Tests;
@@ -135,13 +136,21 @@ public sealed class ServerTests
public Task<MediaSessionCrypto> TakeMediaCryptoAsync() => connection.TakeMediaCryptoAsync(Timeout.Token);
public async Task<Envelope> ReadUntilAsync(Func<Envelope, bool> predicate)
{
while (await messages.MoveNextAsync()) if (predicate(messages.Current)) return messages.Current;
while (await messages.MoveNextAsync())
{
if (messages.Current.AuthResult?.Ok == true) Authentication = messages.Current.AuthResult;
if (predicate(messages.Current)) return messages.Current;
}
throw new IOException("Connection ended before the expected message.");
}
public async Task<User> LoginAsync(string nickname)
{
Send(new() { RequestId = 1, ClientHello = new() { ProtoVersion = 2, ClientName = "Managed test" } });
Assert.Equal(1UL, (await ReadUntilAsync(e => e.ServerHello is not null)).RequestId);
var hello = new ClientHello { ProtoVersion = 2, ClientName = "Managed test" };
hello.Features.Add(ProtocolFeatures.AdaptivePacketLoss);
Send(new() { RequestId = 1, ClientHello = hello });
Envelope response = await ReadUntilAsync(e => e.ServerHello is not null);
Assert.Equal(1UL, response.RequestId);
Assert.Contains(ProtocolFeatures.AdaptivePacketLoss, response.ServerHello.Features);
Send(new() { RequestId = 2, AuthRequest = new() { Guest = new() { Nickname = nickname } } });
AuthResult auth = (await ReadUntilAsync(e => e.AuthResult is not null)).AuthResult;
Authentication = auth;