Moh werrk?

This commit is contained in:
Cyberboss
2018-06-29 16:50:14 -04:00
parent 85df54f4f2
commit ec248029ba
5 changed files with 76 additions and 2 deletions
@@ -57,6 +57,16 @@ namespace Tgstation.Server.Host.Components
}
}
/// <inheritdoc />
public DreamDaemonRebootState RebootState
{
get
{
CheckDisposed();
return reattachInformation.RebootState;
}
}
/// <summary>
/// The up to date <see cref="DreamDaemonReattachInformation"/>
/// </summary>
@@ -209,5 +219,14 @@ namespace Tgstation.Server.Host.Components
throw new ArgumentOutOfRangeException(nameof(port), port, "port must not be zero!");
return await SetPortImpl(port, cancellatonToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<bool> SetRebootState(DreamDaemonRebootState newRebootState, CancellationToken cancellationToken)
{
var oldActive = RebootState != DreamDaemonRebootState.Normal;
var newActive = RebootState != DreamDaemonRebootState.Normal;
if (oldActive == newActive)
return true;
}
}
}
@@ -27,6 +27,11 @@ namespace Tgstation.Server.Host.Components
/// </summary>
public ushort Port { get; set; }
/// <summary>
/// The current DreamDaemon reboot state
/// </summary>
public DreamDaemonRebootState RebootState { get; set; }
/// <summary>
/// The <see cref="IDmbProvider"/> used by DreamDaemon
/// </summary>
@@ -0,0 +1,21 @@
namespace Tgstation.Server.Host.Components
{
/// <summary>
/// Represents the action to take when /world/Reboot() is called
/// </summary>
enum DreamDaemonRebootState
{
/// <summary>
/// Run DreamDaemon's normal reboot process
/// </summary>
Normal,
/// <summary>
/// Shutdown DreamDaemon
/// </summary>
Shutdown,
/// <summary>
/// Restart the DreamDaemon process
/// </summary>
Restart
}
}
@@ -7,8 +7,8 @@ namespace Tgstation.Server.Host.Components
/// <summary>
/// Handles communication with a <see cref="IDreamDaemonSession"/>
/// </summary>
interface IDreamDaemonControl : IDisposable
{
interface IDreamDaemonControl : IDisposable
{
/// <summary>
/// If the <see cref="IDmbProvider.PrimaryDirectory"/> of <see cref="Dmb"/> is being used
/// </summary>
@@ -24,6 +24,11 @@ namespace Tgstation.Server.Host.Components
/// </summary>
ushort Port { get; }
/// <summary>
/// The current <see cref="DreamDaemonRebootState"/>
/// </summary>
DreamDaemonRebootState RebootState { get; }
/// <summary>
/// Releases the <see cref="IDreamDaemonSession"/> without terminating it. Also calls <see cref="IDisposable.Dispose"/>
/// </summary>
@@ -50,5 +55,13 @@ namespace Tgstation.Server.Host.Components
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the operation succeeded, <see langword="false"/> otherwise</returns>
Task<bool> SetPort(ushort newPort, CancellationToken cancellatonToken);
/// <summary>
/// Attempts to change the current <see cref="RebootState"/> to <paramref name="newRebootState"/>
/// </summary>
/// <param name="newRebootState">The new <see cref="DreamDaemonRebootState"/></param>
/// <param name="cancellatonToken">The <see cref="CancellationToken"/> for the operation</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if the operation succeeded, <see langword="false"/> otherwise</returns>
Task<bool> SetRebootState(DreamDaemonRebootState newRebootState, CancellationToken cancellationToken);
}
}
@@ -0,0 +1,16 @@
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models.Internal;
namespace Tgstation.Server.Host.Components
{
/// <summary>
/// Factory for <see cref="IDreamDaemonControl"/>s
/// </summary>
interface IDreamDaemonFactory
{
IDreamDaemonControl LaunchNew(DreamDaemonLaunchParameters launchParameters);
Task<IDreamDaemonControl> Reattach(DreamDaemonReattachInformation reattachInformation, CancellationToken cancellationToken);
}
}