Add adaptive packet loss handling
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user