From ca0b29c6ec465adb040de9ecca16d746cd9c701c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 25 Sep 2018 23:20:00 -0400 Subject: [PATCH] Adds DeadSessionController --- .../Watchdog/DeadSessionController.cs | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/Tgstation.Server.Host/Components/Watchdog/DeadSessionController.cs diff --git a/src/Tgstation.Server.Host/Components/Watchdog/DeadSessionController.cs b/src/Tgstation.Server.Host/Components/Watchdog/DeadSessionController.cs new file mode 100644 index 0000000000..cccd429723 --- /dev/null +++ b/src/Tgstation.Server.Host/Components/Watchdog/DeadSessionController.cs @@ -0,0 +1,99 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Tgstation.Server.Host.Components.Watchdog +{ + /// + /// Implements a fake "dead" + /// + sealed class DeadSessionController : ISessionController + { + /// + public Task LaunchResult { get; } + + /// + public bool IsPrimary => false; + + /// + public bool TerminationWasRequested => true; + + /// + public ApiValidationStatus ApiValidationStatus => throw new NotSupportedException(); + + /// + public IDmbProvider Dmb { get; } + + /// + public ushort? Port => null; + + /// + public bool ClosePortOnReboot + { + get => throw new NotSupportedException(); + set => throw new NotSupportedException(); + } + + /// + public RebootState RebootState => throw new NotSupportedException(); + + /// + public Task OnReboot { get; } + + /// + public Task Lifetime { get; } + + /// + /// If the was d + /// + bool disposed; + + /// + /// Construct a + /// + /// The value of + public DeadSessionController(IDmbProvider dmbProvider) + { + Dmb = dmbProvider ?? throw new ArgumentNullException(nameof(dmbProvider)); + LaunchResult = Task.FromResult(new LaunchResult + { + StartupTime = TimeSpan.FromSeconds(0) + }); + Lifetime = Task.FromResult(-1); + OnReboot = new TaskCompletionSource().Task; + } + + /// + public void Dispose() + { + lock (this) + { + if (disposed) + return; + disposed = true; + } + Dmb.Dispose(); + } + + /// + public void EnableCustomChatCommands() => throw new NotSupportedException(); + + /// + public ReattachInformation Release() => throw new NotSupportedException(); + + /// + public void ResetRebootState() => throw new NotSupportedException(); + + /// + public Task SendCommand(string command, CancellationToken cancellationToken) => throw new NotSupportedException(); + + /// + public void SetHighPriority() => throw new NotSupportedException(); + + /// + public Task SetPort(ushort newPort, CancellationToken cancellatonToken) => throw new NotSupportedException(); + + /// + public Task SetRebootState(RebootState newRebootState, CancellationToken cancellationToken) => throw new NotSupportedException(); + } +}