disconnect with ctrl c

This commit is contained in:
JohnCorby 2025-02-24 14:08:22 -08:00
parent 8d239a41b5
commit d03ad707cd
3 changed files with 18 additions and 29 deletions

View File

@ -58,19 +58,7 @@ public class Client
}
_transport.Log($"connecting to {address}");
var options = new SteamNetworkingConfigValue_t[]
{
new SteamNetworkingConfigValue_t
{
m_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_IP_AllowWithoutAuth,
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
m_val = new SteamNetworkingConfigValue_t.OptionValue
{
m_int32 = 1,
}
}
};
_conn = SteamNetworkingSockets.ConnectByIPAddress(ref steamAddr, options.Length, options);
_conn = SteamNetworkingSockets.ConnectByIPAddress(ref steamAddr, 0, new SteamNetworkingConfigValue_t[0]);
}
public void Send(ArraySegment<byte> segment, int channelId)

View File

@ -1,8 +1,6 @@
using HarmonyLib;
using Steamworks;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace SteamTransport;
@ -77,7 +75,13 @@ public static class Program
try
{
while (true)
var running = true;
Console.CancelKeyPress += (sender, args) =>
{
args.Cancel = true;
running = false;
};
while (running)
{
transport.ServerEarlyUpdate();
SteamAPI.RunCallbacks();
@ -103,15 +107,18 @@ public static class Program
try
{
var stopwatch = Stopwatch.StartNew();
while (true)
var running = true;
Console.CancelKeyPress += (sender, args) =>
{
args.Cancel = true;
running = false;
};
while (running)
{
transport.ClientEarlyUpdate();
SteamAPI.RunCallbacks();
transport.ClientLateUpdate();
Thread.Sleep(10);
if (stopwatch.ElapsedMilliseconds > 10 * 1000) break;
}
}
finally

View File

@ -52,17 +52,11 @@ public class Server
public void Send(int connectionId, ArraySegment<byte> segment, int channelId) { }
public void RecieveData()
{
}
public void RecieveData() { }
public void Flush()
{
}
public void Flush() { }
public void Disconnect(int connectionId)
{
}
public void Disconnect(int connectionId) { }
public void Close()
{