mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 15:15:51 +03:00
NormalEndtoEnd test, fixed lockups
This commit is contained in:
parent
d811afc741
commit
503d8964ea
@ -54,6 +54,20 @@ public async Task RelayEndtoEnd()
|
|||||||
await Task.WhenAll( server, client );
|
await Task.WhenAll( server, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task NormalEndtoEnd()
|
||||||
|
{
|
||||||
|
var socket = SteamNetworkingSockets.CreateNormalSocket<TestSocketInterface>( NetAddress.AnyIp( 12445 ) );
|
||||||
|
var server = socket.RunAsync();
|
||||||
|
|
||||||
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
|
var connection = SteamNetworkingSockets.ConnectNormal<TestConnectionInterface>( NetAddress.From( System.Net.IPAddress.Parse( "127.0.0.1" ), 12445 ) );
|
||||||
|
var client = connection.RunAsync();
|
||||||
|
|
||||||
|
await Task.WhenAll( server, client );
|
||||||
|
}
|
||||||
|
|
||||||
private class TestConnectionInterface : ConnectionInterface
|
private class TestConnectionInterface : ConnectionInterface
|
||||||
{
|
{
|
||||||
public override void OnConnectionChanged( ConnectionInfo data )
|
public override void OnConnectionChanged( ConnectionInfo data )
|
||||||
@ -91,13 +105,27 @@ internal async Task RunAsync()
|
|||||||
{
|
{
|
||||||
Console.WriteLine( "[Connection] RunAsync" );
|
Console.WriteLine( "[Connection] RunAsync" );
|
||||||
|
|
||||||
while ( !Connected )
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
|
while ( Connecting )
|
||||||
|
{
|
||||||
await Task.Delay( 10 );
|
await Task.Delay( 10 );
|
||||||
|
|
||||||
|
if ( sw.Elapsed.TotalSeconds > 30 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !Connected )
|
||||||
|
{
|
||||||
|
Console.WriteLine( "[Connection] Couldn't connect!" );
|
||||||
|
Console.WriteLine( Connection.DetailedStatus() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine( "[Connection] Hey We're Connected!" );
|
Console.WriteLine( "[Connection] Hey We're Connected!" );
|
||||||
|
|
||||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
|
||||||
|
|
||||||
|
sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
while ( Connected )
|
while ( Connected )
|
||||||
{
|
{
|
||||||
Receive();
|
Receive();
|
||||||
@ -186,9 +214,19 @@ public override void OnDisconnected( Connection connection, ConnectionInfo data
|
|||||||
|
|
||||||
internal async Task RunAsync()
|
internal async Task RunAsync()
|
||||||
{
|
{
|
||||||
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
while ( Connected.Count == 0 )
|
while ( Connected.Count == 0 )
|
||||||
|
{
|
||||||
await Task.Delay( 10 );
|
await Task.Delay( 10 );
|
||||||
|
|
||||||
|
if ( sw.Elapsed.TotalSeconds > 2 )
|
||||||
|
{
|
||||||
|
Assert.Fail( "Client Took Too Long To Connect" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await Task.Delay( 1000 );
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
var singleClient = Connected.First();
|
var singleClient = Connected.First();
|
||||||
@ -205,7 +243,7 @@ internal async Task RunAsync()
|
|||||||
await Task.Delay( 100 );
|
await Task.Delay( 100 );
|
||||||
singleClient.SendMessage( "Hello Client!?" );
|
singleClient.SendMessage( "Hello Client!?" );
|
||||||
|
|
||||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
while ( Connected.Contains( singleClient ) )
|
while ( Connected.Contains( singleClient ) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user