CatStation/Content.Client/Launcher/ExtendedDisconnectInformationManager.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

45 lines
1.3 KiB
C#

using System;
using Robust.Client;
using Robust.Client.UserInterface;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
namespace Content.Client.Launcher;
/// <summary>
/// So apparently the way that disconnect information is shipped around is really indirect.
/// But honestly, given that content might have additional flags (i.e. hide disconnect button for bans)?
/// This is responsible for collecting any extended disconnect information.
/// </summary>
public sealed partial class ExtendedDisconnectInformationManager
{
[Dependency] private IClientNetManager _clientNetManager = default!;
private NetDisconnectedArgs? _lastNetDisconnectedArgs = null;
public NetDisconnectedArgs? LastNetDisconnectedArgs
{
get => _lastNetDisconnectedArgs;
private set
{
_lastNetDisconnectedArgs = value;
LastNetDisconnectedArgsChanged?.Invoke(value);
}
}
// BE CAREFUL!
// This may fire at an arbitrary time before or after whatever code that needs it.
public event Action<NetDisconnectedArgs?>? LastNetDisconnectedArgsChanged;
public void Initialize()
{
_clientNetManager.Disconnect += OnNetDisconnect;
}
private void OnNetDisconnect(object? sender, NetDisconnectedArgs args)
{
LastNetDisconnectedArgs = args;
}
}