32 lines
822 B
C#
Raw Normal View History

2020-12-04 09:29:23 +00:00
using System.Collections.Generic;
2020-12-02 12:42:26 +00:00
using UnityEngine;
using UnityEngine.Networking.Types;
2020-12-02 21:19:10 +00:00
namespace QSB.QuantumUNET
2020-12-02 12:42:26 +00:00
{
public class QSBUtility
{
2020-12-03 11:56:32 +00:00
private static readonly Dictionary<NetworkID, NetworkAccessToken> _dictTokens = new Dictionary<NetworkID, NetworkAccessToken>();
2020-12-02 12:42:26 +00:00
2020-12-04 09:29:23 +00:00
public static SourceID GetSourceID()
2020-12-03 11:56:32 +00:00
=> (SourceID)SystemInfo.deviceUniqueIdentifier.GetHashCode();
2020-12-02 12:42:26 +00:00
public static void SetAccessTokenForNetwork(NetworkID netId, NetworkAccessToken accessToken)
{
2020-12-03 11:56:32 +00:00
if (_dictTokens.ContainsKey(netId))
2020-12-02 12:42:26 +00:00
{
2020-12-03 11:56:32 +00:00
_dictTokens.Remove(netId);
2020-12-02 12:42:26 +00:00
}
2020-12-03 11:56:32 +00:00
_dictTokens.Add(netId, accessToken);
2020-12-02 12:42:26 +00:00
}
public static NetworkAccessToken GetAccessTokenForNetwork(NetworkID netId)
{
2020-12-03 11:56:32 +00:00
if (!_dictTokens.TryGetValue(netId, out var result))
2020-12-02 12:42:26 +00:00
{
result = new NetworkAccessToken();
}
return result;
}
}
2020-12-03 08:28:05 +00:00
}