0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Core/Patches/WebSocketPatch.cs

27 lines
1.0 KiB
C#
Raw Normal View History

2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
2023-03-03 18:52:31 +00:00
using System;
using System.Reflection;
2024-05-21 19:10:17 +01:00
namespace SPT.Core.Patches
2023-03-03 18:52:31 +00:00
{
public class WebSocketPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var targetInterface = PatchConstants.EftTypes.SingleCustom(x => x == typeof(IConnectionHandler) && x.IsInterface);
var typeThatMatches = PatchConstants.EftTypes.SingleCustom(x => targetInterface.IsAssignableFrom(x) && x.IsAbstract && !x.IsInterface);
return typeThatMatches.GetMethods(BindingFlags.Public | BindingFlags.Instance).SingleCustom(x => x.ReturnType == typeof(Uri));
2023-03-03 18:52:31 +00:00
}
// This is a pass through postfix and behaves a little differently than usual
// https://harmony.pardeike.net/articles/patching-postfix.html#pass-through-postfixes
2023-03-03 18:52:31 +00:00
[PatchPostfix]
private static Uri PatchPostfix(Uri __result)
2023-03-03 18:52:31 +00:00
{
return new Uri(__result.ToString().Replace("wss:", "ws:"));
2023-03-03 18:52:31 +00:00
}
}
}