30 lines
927 B
C#
30 lines
927 B
C#
using Content.Shared._CP14.Discord;
|
|
using Robust.Client.State;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Client._CP14.Discord;
|
|
|
|
public sealed class DiscordAuthManager
|
|
{
|
|
[Dependency] private readonly IClientNetManager _netManager = default!;
|
|
[Dependency] private readonly IStateManager _stateManager = default!;
|
|
|
|
public string AuthUrl { get; private set; } = "";
|
|
public string ErrorMessage { get; private set; } = "";
|
|
|
|
public void Initialize()
|
|
{
|
|
_netManager.RegisterNetMessage<MsgDiscordAuthCheck>();
|
|
_netManager.RegisterNetMessage<MsgDiscordAuthRequired>(OnDiscordAuthRequired);
|
|
}
|
|
|
|
private void OnDiscordAuthRequired(MsgDiscordAuthRequired msg)
|
|
{
|
|
if (_stateManager.CurrentState is DiscordAuthState)
|
|
return;
|
|
AuthUrl = msg.AuthUrl;
|
|
ErrorMessage = msg.ErrorMessage;
|
|
_stateManager.RequestStateChange<DiscordAuthState>();
|
|
}
|
|
}
|