Files
Reactor/Reactor.Debugger/Patches/DisableTimeoutPatch.cs
T
2024-03-02 13:02:53 +01:00

28 lines
718 B
C#

using HarmonyLib;
using Hazel.Udp;
namespace Reactor.Debugger.Patches;
[HarmonyPatch]
internal static class DisableTimeoutPatch
{
private static bool Enabled => DebuggerConfig.DisableTimeout.Value;
[HarmonyPatch(typeof(UdpConnection), nameof(UdpConnection.HandleKeepAlive))]
[HarmonyPrefix]
public static bool DisableKeepAlive()
{
return !Enabled;
}
[HarmonyPatch(typeof(UnityUdpClientConnection), nameof(UnityUdpClientConnection.ConnectAsync))]
[HarmonyPostfix]
public static void DisableTimeout(UnityUdpClientConnection __instance)
{
if (!Enabled) return;
__instance.DisconnectTimeoutMs = int.MaxValue;
__instance.ResendLimit = 0;
}
}