21 lines
507 B
C#
21 lines
507 B
C#
using System.Collections.Concurrent;
|
|
|
|
namespace FishGameService.GameService
|
|
{
|
|
public interface IReconnectTracker
|
|
{
|
|
bool TryAdd(string userId);
|
|
|
|
void Remove(string userId);
|
|
}
|
|
|
|
public class ReconnectTracker : IReconnectTracker
|
|
{
|
|
private readonly ConcurrentDictionary<string, byte> _tracking = new();
|
|
|
|
public bool TryAdd(string userId) => _tracking.TryAdd(userId, 0);
|
|
|
|
public void Remove(string userId) => _tracking.TryRemove(userId, out _);
|
|
}
|
|
}
|