mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 14:48:02 +03:00
Add fake IP test cases
This commit is contained in:
parent
0455e7fc72
commit
30ff3a3d85
@ -51,6 +51,24 @@ namespace Steamworks
|
|||||||
si.Close();
|
si.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task CreateRelayServerFakeIP()
|
||||||
|
{
|
||||||
|
SteamNetworkingUtils.DebugLevel = NetDebugOutput.Everything;
|
||||||
|
SteamNetworkingUtils.OnDebugOutput += DebugOutput;
|
||||||
|
|
||||||
|
SteamNetworkingSockets.RequestFakeIP();
|
||||||
|
|
||||||
|
var si = SteamNetworkingSockets.CreateRelaySocketFakeIP<TestSocketInterface>();
|
||||||
|
|
||||||
|
Console.WriteLine( $"Created Socket: {si}" );
|
||||||
|
|
||||||
|
// Give it a second for something to happen
|
||||||
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
|
si.Close();
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task RelayEndtoEnd()
|
public async Task RelayEndtoEnd()
|
||||||
{
|
{
|
||||||
@ -102,6 +120,36 @@ namespace Steamworks
|
|||||||
await Task.WhenAll( server, client );
|
await Task.WhenAll( server, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task RelayEndtoEndFakeIP()
|
||||||
|
{
|
||||||
|
SteamNetworkingUtils.InitRelayNetworkAccess();
|
||||||
|
SteamNetworkingUtils.DebugLevel = NetDebugOutput.Warning;
|
||||||
|
SteamNetworkingUtils.OnDebugOutput += DebugOutput;
|
||||||
|
|
||||||
|
// For some reason giving steam a couple of seconds here
|
||||||
|
// seems to prevent it returning null connections from ConnectNormal
|
||||||
|
await Task.Delay( 2000 );
|
||||||
|
|
||||||
|
Console.WriteLine( $"----- Requesting Fake IP.." );
|
||||||
|
SteamNetworkingSockets.RequestFakeIP();
|
||||||
|
|
||||||
|
Console.WriteLine( $"----- Creating Socket Relay Socket.." );
|
||||||
|
var socket = SteamNetworkingSockets.CreateRelaySocketFakeIP<TestSocketInterface>();
|
||||||
|
var server = socket.RunAsync();
|
||||||
|
|
||||||
|
await Task.Delay( 1000 );
|
||||||
|
|
||||||
|
Console.WriteLine( $"----- Retrieving Fake IP.." );
|
||||||
|
SteamNetworkingSockets.GetFakeIP( 0, out NetAddress address );
|
||||||
|
|
||||||
|
Console.WriteLine( $"----- Connecting To Socket via Fake IP ({address})" );
|
||||||
|
var connection = SteamNetworkingSockets.ConnectNormal<TestConnectionInterface>( address );
|
||||||
|
var client = connection.RunAsync();
|
||||||
|
|
||||||
|
await Task.WhenAll( server, client );
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void NetAddressTest()
|
public void NetAddressTest()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user