mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-12-11 20:15:10 +01:00
more testing
This commit is contained in:
parent
0f9b0015bf
commit
a9b716f7e2
@ -1,5 +1,6 @@
|
|||||||
using Steamworks;
|
using Steamworks;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace SteamTransport;
|
namespace SteamTransport;
|
||||||
|
|
||||||
@ -38,21 +39,26 @@ public static class Program
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SteamClient.SetWarningMessageHook((severity, text) => Console.WriteLine(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Console.ReadKey().KeyChar)
|
switch (Console.ReadKey().KeyChar)
|
||||||
{
|
{
|
||||||
case '1':
|
case '1':
|
||||||
|
Console.WriteLine("server");
|
||||||
DoServer();
|
DoServer();
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
|
Console.WriteLine("client");
|
||||||
DoClient();
|
DoClient();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
SteamAPI.Shutdown();
|
||||||
|
|
||||||
Console.WriteLine("Press any key to exit");
|
Console.WriteLine("Press any key to exit");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
@ -60,17 +66,40 @@ public static class Program
|
|||||||
|
|
||||||
private static void DoServer()
|
private static void DoServer()
|
||||||
{
|
{
|
||||||
|
using var cb = Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t>.Create(t =>
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{t.m_info.m_szConnectionDescription} | state = {t.m_info.m_eState} | {(ESteamNetConnectionEnd)t.m_info.m_eEndReason} {t.m_info.m_szEndDebug}");
|
||||||
|
});
|
||||||
|
|
||||||
var address = new SteamNetworkingIPAddr();
|
var address = new SteamNetworkingIPAddr();
|
||||||
address.SetIPv6LocalHost();
|
address.Clear();
|
||||||
var socket = SteamNetworkingSockets.CreateListenSocketIP(ref address, 0, new SteamNetworkingConfigValue_t[0]);
|
var socket = SteamNetworkingSockets.CreateListenSocketIP(ref address, 0, new SteamNetworkingConfigValue_t[0]);
|
||||||
|
Console.WriteLine("listening...");
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
SteamAPI.RunCallbacks();
|
||||||
|
Thread.Sleep(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DoClient()
|
private static void DoClient()
|
||||||
{
|
{
|
||||||
|
using var cb = Steamworks.Callback<SteamNetConnectionStatusChangedCallback_t>.Create(t =>
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{t.m_info.m_szConnectionDescription} | state = {t.m_info.m_eState} | {(ESteamNetConnectionEnd)t.m_info.m_eEndReason} {t.m_info.m_szEndDebug}");
|
||||||
|
});
|
||||||
|
|
||||||
var address = new SteamNetworkingIPAddr();
|
var address = new SteamNetworkingIPAddr();
|
||||||
address.SetIPv6LocalHost();
|
address.SetIPv6LocalHost();
|
||||||
|
Console.WriteLine($"is localhost = {address.IsLocalHost()}");
|
||||||
var conn = SteamNetworkingSockets.ConnectByIPAddress(ref address, 0, new SteamNetworkingConfigValue_t[0]);
|
var conn = SteamNetworkingSockets.ConnectByIPAddress(ref address, 0, new SteamNetworkingConfigValue_t[0]);
|
||||||
|
Console.WriteLine("connecting...");
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
SteamAPI.RunCallbacks();
|
||||||
|
Thread.Sleep(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user