2020-12-04 22:14:53 +00:00

32 lines
818 B
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking.Types;
namespace QuantumUNET
{
public class QSBUtility
{
private static readonly Dictionary<NetworkID, NetworkAccessToken> _dictTokens = new Dictionary<NetworkID, NetworkAccessToken>();
public static SourceID GetSourceID()
=> (SourceID)SystemInfo.deviceUniqueIdentifier.GetHashCode();
public static void SetAccessTokenForNetwork(NetworkID netId, NetworkAccessToken accessToken)
{
if (_dictTokens.ContainsKey(netId))
{
_dictTokens.Remove(netId);
}
_dictTokens.Add(netId, accessToken);
}
public static NetworkAccessToken GetAccessTokenForNetwork(NetworkID netId)
{
if (!_dictTokens.TryGetValue(netId, out var result))
{
result = new NetworkAccessToken();
}
return result;
}
}
}