Files
crystall-punk-14/Content.Client/_CP14/Discord/CP14DiscordAuthState.cs
Ed b2234b7c4a Discord authentification (#819)
* Auth setup

* fixes

* messages

* adapt to new auth

* cvar fix

* generating link setup

* new version adapt

* fix

* Update DiscordAuthManager.cs
2025-02-04 22:44:22 +03:00

37 lines
1.0 KiB
C#

using System.Threading;
using Content.Shared._CP14.Discord;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.Network;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Client._CP14.Discord;
public sealed class DiscordAuthState : State
{
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
private DiscordAuthGui? _gui;
private readonly CancellationTokenSource _checkTimerCancel = new();
protected override void Startup()
{
_gui = new DiscordAuthGui();
_userInterfaceManager.StateRoot.AddChild(_gui);
Timer.SpawnRepeating(TimeSpan.FromSeconds(5),
() =>
{
_netManager.ClientSendMessage(new MsgDiscordAuthCheck());
},
_checkTimerCancel.Token);
}
protected override void Shutdown()
{
_checkTimerCancel.Cancel();
_gui!.Dispose();
}
}