2023-06-09 22:32:56 -07:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Sockets;
|
2023-06-09 22:47:31 -07:00
|
|
|
|
using static SteamRerouter.ModSide.Interop;
|
2023-06-09 22:32:56 -07:00
|
|
|
|
|
|
|
|
|
namespace SteamRerouter.ModSide;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// handles communication with the exe
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Socket
|
|
|
|
|
{
|
|
|
|
|
private static TcpListener _listener;
|
|
|
|
|
private static TcpClient _tcpClient;
|
|
|
|
|
|
|
|
|
|
public static int Listen()
|
|
|
|
|
{
|
|
|
|
|
_listener = new TcpListener(IPAddress.Loopback, 0);
|
|
|
|
|
_listener.Start();
|
|
|
|
|
var port = ((IPEndPoint)_listener.LocalEndpoint).Port;
|
2023-06-09 22:47:31 -07:00
|
|
|
|
Log($"port is {port}");
|
2023-06-09 22:32:56 -07:00
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Accept()
|
|
|
|
|
{
|
2023-06-09 22:47:31 -07:00
|
|
|
|
Log("accepting");
|
2023-06-09 22:32:56 -07:00
|
|
|
|
_tcpClient = _listener.AcceptTcpClient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Quit()
|
|
|
|
|
{
|
2023-06-09 22:47:31 -07:00
|
|
|
|
Log("quitting");
|
2023-06-09 22:32:56 -07:00
|
|
|
|
_listener.Stop();
|
|
|
|
|
_tcpClient.Close();
|
|
|
|
|
}
|
2023-06-09 22:47:31 -07:00
|
|
|
|
|
|
|
|
|
public static EntitlementsManager.AsyncOwnershipStatus SteamEntitlementRetriever_GetOwnershipStatus()
|
|
|
|
|
{
|
|
|
|
|
Log("get ownership status");
|
|
|
|
|
return EntitlementsManager.AsyncOwnershipStatus.Owned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Achievements_Earn(Achievements.Type type)
|
|
|
|
|
{
|
|
|
|
|
Log($"earn achievement {type}");
|
|
|
|
|
}
|
2023-06-09 22:32:56 -07:00
|
|
|
|
}
|