mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-23 19:42:51 +01:00
26 lines
727 B
C#
26 lines
727 B
C#
using System.Collections.Concurrent;
|
|
|
|
namespace Phantom.Web.Services.Authentication;
|
|
|
|
public sealed class UserSessionRefreshManager {
|
|
private readonly ConcurrentDictionary<Guid, EventHolder> userUpdateEventHoldersByUserGuid = new ();
|
|
|
|
internal EventHolder GetEventHolder(Guid userGuid) {
|
|
return userUpdateEventHoldersByUserGuid.GetOrAdd(userGuid, static _ => new EventHolder());
|
|
}
|
|
|
|
internal void RefreshUser(Guid userGuid) {
|
|
if (userUpdateEventHoldersByUserGuid.TryGetValue(userGuid, out var eventHolder)) {
|
|
eventHolder.Notify();
|
|
}
|
|
}
|
|
|
|
internal sealed class EventHolder {
|
|
public event EventHandler? UserNeedsRefresh;
|
|
|
|
internal void Notify() {
|
|
UserNeedsRefresh?.Invoke(null, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|