More features
This commit is contained in:
@@ -1,25 +1,15 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Steamworks;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Services;
|
||||
|
||||
public class SteamSessionService : IDisposable
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, ulong> _validatedSessionTickets;
|
||||
private readonly ConcurrentDictionary<string, ulong> _validatedSessionTickets = new();
|
||||
private readonly object _initLock = new();
|
||||
private bool _steamInitialized;
|
||||
|
||||
private const int ShadowVerseAppId = 453480;
|
||||
|
||||
public SteamSessionService()
|
||||
{
|
||||
_validatedSessionTickets = new ConcurrentDictionary<string, ulong>();
|
||||
SteamServer.Init(ShadowVerseAppId, new SteamServerInit
|
||||
{
|
||||
GamePort = default,
|
||||
QueryPort = default
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates if a given session ticket is valid, and matches up with the given steamid.
|
||||
@@ -34,6 +24,8 @@ public class SteamSessionService : IDisposable
|
||||
return storedSteamId == steamId;
|
||||
}
|
||||
|
||||
EnsureSteamInitialized();
|
||||
|
||||
List<byte> ticketBytes = new List<byte>();
|
||||
for (int i = 0; i < ticket.Length; i += 2)
|
||||
{
|
||||
@@ -45,12 +37,30 @@ public class SteamSessionService : IDisposable
|
||||
{
|
||||
_validatedSessionTickets.TryAdd(ticket, steamId);
|
||||
}
|
||||
|
||||
|
||||
return steamCheckResults;
|
||||
}
|
||||
|
||||
private void EnsureSteamInitialized()
|
||||
{
|
||||
if (_steamInitialized) return;
|
||||
lock (_initLock)
|
||||
{
|
||||
if (_steamInitialized) return;
|
||||
SteamServer.Init(ShadowVerseAppId, new SteamServerInit
|
||||
{
|
||||
GamePort = default,
|
||||
QueryPort = default
|
||||
});
|
||||
_steamInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SteamServer.Shutdown();
|
||||
if (_steamInitialized)
|
||||
{
|
||||
SteamServer.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user