2using System.Collections.Generic;
3using System.Globalization;
7using System.Threading.Tasks;
9using Microsoft.Extensions.Logging;
10using Microsoft.Extensions.Logging.Abstractions;
39 internal static bool LogTopicRequests {
get;
set; } =
true;
50 throw new InvalidOperationException(
"ApiValidated cannot be checked while Lifetime is incomplete!");
88 var tcs =
new TaskCompletionSource<Task>();
91 var toAwait = await tcs.Task;
96 tcs.SetResult(Interlocked.Exchange(ref
rebootGate, Wrap()));
288 ILogger<SessionController> logger,
289 Func<ValueTask> postLifetimeCallback,
290 uint? startupTimeout,
295 ReattachInformation = reattachInformation ??
throw new ArgumentNullException(nameof(reattachInformation));
296 this.metadata =
metadata ??
throw new ArgumentNullException(nameof(
metadata));
297 this.process =
process ??
throw new ArgumentNullException(nameof(
process));
301 ArgumentNullException.ThrowIfNull(bridgeRegistrar);
303 this.chat =
chat ??
throw new ArgumentNullException(nameof(
chat));
304 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
318 primeTcs =
new TaskCompletionSource();
339 "Not registering session with {reasonWhyDmApiIsBad} DMAPI version for interop!",
342 : $
"incompatible ({reattachInformation.Dmb.CompileJob.DMApiVersion})");
344 async Task<int?> WrapLifetime()
347 await postLifetimeCallback();
357 assemblyInformationProvider,
364 "Created session controller. CommsKey: {accessIdentifier}, Port: {port}",
366 reattachInformation.
Port);
379 Logger.LogTrace(
"Disposing...");
382 var cancellationToken = CancellationToken.None;
400 if (initialDmb !=
null)
401 await initialDmb.DisposeAsync();
403 await regularDmbDisposeTask;
411 (await semaphoreLockTask).Dispose();
420 ArgumentNullException.ThrowIfNull(parameters);
424 Logger.LogTrace(
"Handling bridge request...");
451 =>
SendCommand(parameters,
false, cancellationToken);
459 Logger.LogTrace(
"Changing reboot state to {newRebootState}", newRebootState);
461 ReattachInformation.RebootState = newRebootState;
466 return result !=
null && result.ErrorMessage ==
null;
473 Logger.LogTrace(
"Resetting reboot state...");
474 ReattachInformation.RebootState =
RebootState.Normal;
490 ReattachInformation.Dmb = dmbProvider ??
throw new ArgumentNullException(nameof(dmbProvider));
495 public async ValueTask
InstanceRenamed(
string newInstanceName, CancellationToken cancellationToken)
498 if (runtimeInformation !=
null)
499 runtimeInformation.InstanceName = newInstanceName;
507 public async ValueTask
UpdateChannels(IEnumerable<ChannelRepresentation> newChannels, CancellationToken cancellationToken)
514 public ValueTask
CreateDump(
string outputFile,
bool minidump, CancellationToken cancellationToken)
538 uint? startupTimeout,
542 var startTime = DateTimeOffset.UtcNow;
543 var useBridgeRequestForLaunchResult = !reattached && (apiValidate ||
DMApiAvailable);
544 var startupTask = useBridgeRequestForLaunchResult
545 ? initialBridgeRequestTcs.Task
549 if (startupTimeout.HasValue)
550 toAwait = Task.WhenAny(
553 TimeSpan.FromSeconds(startupTimeout.Value),
554 CancellationToken.None)
558 "Waiting for LaunchResult based on {launchResultCompletionCause}{possibleTimeout}...",
559 useBridgeRequestForLaunchResult ?
"initial bridge request" :
"process startup",
560 startupTimeout.HasValue ? $
" with a timeout of {startupTimeout.Value}s" : String.Empty);
566 ExitCode = process.Lifetime.IsCompleted ? await process.Lifetime :
null,
567 StartupTime = startupTask.IsCompleted ? (DateTimeOffset.UtcNow - startTime) :
null,
570 Logger.LogTrace(
"Launch result: {launchResult}", result);
572 if (!result.ExitCode.HasValue && reattached && !
disposed)
576 assemblyInformationProvider.
Version,
581 if (reattachResponse !=
null)
583 if (reattachResponse?.CustomCommands !=
null)
584 chatTrackingContext.CustomCommands = reattachResponse.CustomCommands;
585 else if (reattachResponse !=
null)
590 "DMAPI Interop v{interopVersion} isn't returning the TGS custom commands list. Functionality added in v5.2.0.",
610 Logger.LogTrace(
"Entered post validation terminate task.");
611 if (!await proceedTask)
613 Logger.LogTrace(
"Not running post validation terminate task for repeated bridge request.");
617 const int GracePeriodSeconds = 30;
618 Logger.LogDebug(
"Server will terminated in {gracePeriodSeconds}s if it does not exit...", GracePeriodSeconds);
619 var delayTask =
asyncDelayer.
Delay(TimeSpan.FromSeconds(GracePeriodSeconds), CancellationToken.None).AsTask();
624 Logger.LogWarning(
"DMAPI took too long to shutdown server after validation request!");
629 Logger.LogTrace(
"Server exited properly post validation.");
638#pragma warning disable CA1502
649 return BridgeError(
"Missing channelIds field in chatMessage!");
651 if (parameters.
ChatMessage.
ChannelIds.Any(channelIdString => !UInt64.TryParse(channelIdString, out var _)))
652 return BridgeError(
"Invalid channelIds in chatMessage!");
655 return BridgeError(
"Missing message field in chatMessage!");
657 var anyFailed =
false;
661 anyFailed |= !UInt64.TryParse(channelString, out var channelId);
666 return BridgeError(
"Failed to parse channelIds as U64!");
673 Interlocked.Exchange(ref
primeTcs,
new TaskCompletionSource()).SetResult();
676 Logger.LogInformation(
"Bridge requested process termination!");
677 chatTrackingContext.Active =
false;
682 return BridgeError(
"Port switching is no longer supported!");
688 var proceedTcs =
new TaskCompletionSource<bool>();
690 proceedTcs.SetResult(firstValidationRequest);
692 if (!firstValidationRequest)
693 return BridgeError(
"Startup bridge request was repeated!");
696 if (parameters.
Version ==
null)
721 return BridgeError(
"Missing minimumSecurityLevel field!");
723 return BridgeError(
"Invalid minimumSecurityLevel!");
741 var newTopicPort = parameters.
TopicPort.Value;
742 Logger.LogInformation(
"Server is requesting use of port {topicPort} for topic communications", newTopicPort);
743 ReattachInformation.TopicPort = newTopicPort;
747 chatTrackingContext.CustomCommands = parameters.CustomCommands ?? Array.Empty<
CustomCommand>();
748 chatTrackingContext.Active =
true;
749 Interlocked.Exchange(ref
startupTcs,
new TaskCompletionSource()).SetResult();
755 chatTrackingContext.Active =
false;
756 Interlocked.Exchange(ref
rebootTcs,
new TaskCompletionSource()).SetResult();
757 await
RebootGate.WaitAsync(cancellationToken);
772 return BridgeError($
"commandType {parameters.CommandType} not supported!");
777#pragma warning restore CA1502
786 Logger.LogWarning(
"Bridge request error: {message}", message);
789 ErrorMessage = message,
804 if (LogTopicRequests)
805 Logger.LogTrace(
"Topic request: {json}", json);
806 var fullCommandByteCount = Encoding.UTF8.GetByteCount(fullCommandString);
809 return await
SendRawTopic(fullCommandString, topicPriority, cancellationToken);
811 var interopChunkingVersion =
new Version(5, 6, 0);
815 "Cannot send topic request as it is exceeds the single request limit of {limitBytes}B ({actualBytes}B) and requires chunking and the current compile job's interop version must be at least {chunkingVersionRequired}!",
817 fullCommandByteCount,
818 interopChunkingVersion);
825 parameters.AccessIdentifier =
null!;
830 var fullPayloadSize = (uint)json.Length;
832 List<string>? chunkQueryStrings =
null;
833 for (var chunkCount = 2; chunkQueryStrings ==
null; ++chunkCount)
835 var standardChunkSize = fullPayloadSize / chunkCount;
836 var bigChunkSize = standardChunkSize + (fullPayloadSize % chunkCount);
840 chunkQueryStrings =
new List<string>();
841 for (var i = 0U; i < chunkCount; ++i)
843 var startIndex = i * standardChunkSize;
844 var subStringLength = Math.Min(
845 fullPayloadSize - startIndex,
848 : standardChunkSize);
849 var chunkPayload = json.Substring((
int)startIndex, (int)subStringLength);
853 Payload = chunkPayload,
854 PayloadId = payloadId,
856 TotalChunks = (uint)chunkCount,
868 chunkQueryStrings =
null;
872 chunkQueryStrings.Add(chunkCommandString);
876 Logger.LogTrace(
"Chunking topic request ({totalChunks} total)...", chunkQueryStrings.Count);
879 bool LogRequestIssue(
bool possiblyFromCompletedRequest)
884 "Topic request {chunkingStatus} failed!{potentialRequestError}",
885 possiblyFromCompletedRequest ?
"final chunk" :
"chunking",
887 ? $
" Request error: {combinedResponse.InteropResponse.ErrorMessage}"
895 foreach (var chunkCommandString
in chunkQueryStrings)
897 combinedResponse = await
SendRawTopic(chunkCommandString, topicPriority, cancellationToken);
898 if (LogRequestIssue(chunkCommandString == chunkQueryStrings.Last()))
902 while ((combinedResponse?.InteropResponse?.MissingChunks?.Count ?? 0) > 0)
904 Logger.LogWarning(
"DD is still missing some chunks of topic request P{payloadId}! Sending missing chunks...", payloadId);
905 var missingChunks = combinedResponse!.InteropResponse!.MissingChunks!;
906 var lastIndex = missingChunks.Last();
907 foreach (var missingChunkIndex
in missingChunks)
909 var chunkCommandString = chunkQueryStrings[(int)missingChunkIndex];
910 combinedResponse = await
SendRawTopic(chunkCommandString, topicPriority, cancellationToken);
911 if (LogRequestIssue(missingChunkIndex == lastIndex))
916 return combinedResponse;
928 var commandString = String.Format(
929 CultureInfo.InvariantCulture,
933 return commandString;
943 async ValueTask<CombinedTopicResponse?>
SendRawTopic(
string queryString,
bool priority, CancellationToken cancellationToken)
948 "Attempted to send a topic on a disposed SessionController");
953 Byond.TopicSender.TopicResponse? byondResponse;
959 : NullLogger.Instance,
965 if (byondResponse ==
null)
969 "Unable to send priority topic \"{queryString}\"!",
975 var topicReturn = byondResponse.StringData;
978 if (topicReturn !=
null)
985 Logger.LogWarning(ex,
"Invalid interop response: {topicReturnString}", topicReturn);
1000 ArgumentNullException.ThrowIfNull(parameters);
1005 "Attempted to send a command to an inactive SessionController: {commandType}",
1012 Logger.LogTrace(
"Not sending topic request {commandType} to server without/with incompatible DMAPI!", parameters.
CommandType);
1017 if (!bypassLaunchResult)
1019 var launchResult = await
LaunchResult.WaitAsync(cancellationToken);
1020 if (launchResult.ExitCode.HasValue)
1022 Logger.LogDebug(
"Not sending topic request {commandType} to server that failed to launch!", parameters.
CommandType);
1030 Logger.LogDebug(
"Not sending topic request {commandType} to server that is rebooting/starting.", parameters.
CommandType);
1034 using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
1035 var combinedCancellationToken = cts.Token;
1036 async ValueTask CancelIfLifetimeElapses()
1040 var completed = await Task.WhenAny(
Lifetime, reboot).WaitAsync(combinedCancellationToken);
1043 "Server {action}, cancelling pending command: {commandType}",
1050 catch (OperationCanceledException)
1056 Logger.LogError(ex,
"Error in CancelIfLifetimeElapses!");
1061 var lifetimeWatchingTask = CancelIfLifetimeElapses();
1064 var combinedResponse = await
SendTopicRequest(parameters, combinedCancellationToken);
1066 void LogCombinedResponse()
1068 if (LogTopicRequests && combinedResponse !=
null)
1069 Logger.LogTrace(
"Topic response: {topicString}", combinedResponse.ByondTopicResponse.StringData ??
"(NO STRING DATA)");
1072 LogCombinedResponse();
1074 if (combinedResponse?.InteropResponse?.
Chunk !=
null)
1076 Logger.LogTrace(
"Topic response is chunked...");
1078 ChunkData? nextChunk = combinedResponse.InteropResponse.Chunk;
1081 var nextRequest = await ProcessChunk<TopicResponse, ChunkedTopicParameters>(
1082 (completedResponse, _) =>
1084 fullResponse = completedResponse;
1089 Logger.LogWarning(
"Topic response chunking error: {message}", error);
1092 combinedResponse?.InteropResponse?.
Chunk,
1093 combinedCancellationToken);
1095 if (nextRequest !=
null)
1097 nextRequest.PayloadId = nextChunk.
PayloadId;
1098 combinedResponse = await
SendTopicRequest(nextRequest, combinedCancellationToken);
1099 LogCombinedResponse();
1100 nextChunk = combinedResponse?.InteropResponse?.Chunk;
1105 while (nextChunk !=
null);
1108 fullResponse = combinedResponse?.InteropResponse;
1110 catch (OperationCanceledException ex)
1114 "Topic request {cancellationType}!",
1115 combinedCancellationToken.IsCancellationRequested
1116 ? cancellationToken.IsCancellationRequested
1122 cancellationToken.ThrowIfCancellationRequested();
1127 await lifetimeWatchingTask;
1130 if (fullResponse?.ErrorMessage !=
null)
1132 "Errored topic response for command {commandType}: {errorMessage}",
1136 return fullResponse;
1146 if (invocation ==
null)
1150 if (eventName ==
null)
1154 if (!notifyCompletion.HasValue)
1157 var eventParams =
new List<string>
1162 eventParams.AddRange(invocation
1164 .Where(param => param !=
null)
1166 ?? Enumerable.Empty<
string>());
1168 var eventId = Guid.NewGuid();
1169 Logger.LogInformation(
"Triggering custom event \"{eventName}\": {eventId}", eventName, eventId);
1174 async Task ProcessEvent()
1181 await eventTask.Value;
1189 if (notifyCompletion.Value)
1193 else if (exception ==
null)
1194 Logger.LogTrace(
"Finished custom event {eventId}, not sending notification.", eventId);
1196 if (exception !=
null)
1199 catch (OperationCanceledException ex)
1201 Logger.LogDebug(ex,
"Custom event invocation {eventId} aborted!", eventId);
1205 Logger.LogWarning(ex,
"Custom event invocation {eventId} errored!", eventId);
1209 if (!eventTask.HasValue)
1210 return BridgeError(
"Event refused to execute due to matching a TGS event!");
1215 var eventProcessingTask = ProcessEvent();
1221 EventId = notifyCompletion.Value
1222 ? eventId.ToString()
Information about an engine installation.
EngineType? Engine
The EngineType.
Metadata about a server instance.
Represents a deployment run.
virtual ? Version DMApiVersion
The DMAPI Version.
Represents a command made from DM code.
Parameters for a bridge request.
BridgeCommandType? CommandType
The BridgeCommandType.
ChatMessage? ChatMessage
The Interop.ChatMessage for BridgeCommandType.ChatSend requests.
CustomEventInvocation? EventInvocation
The CustomEventInvocation being triggered.
ushort? TopicPort
The port that should be used to send world topics, if not the default.
DreamDaemonSecurity? MinimumSecurityLevel
The minimum required DreamDaemonSecurity level for BridgeCommandType.Startup requests.
ChunkData? Chunk
The ChunkData for BridgeCommandType.Chunk requests.
Version? Version
The DMAPI global::System.Version for BridgeCommandType.Startup requests.
A response to a bridge request.
Parameters for invoking a custom event.
string? EventName
The name of the event being invoked.
bool? NotifyCompletion
If the DMAPI should be notified when the event compeletes.
ICollection< string >? ChannelIds
The ICollection<T> of Chat.ChannelRepresentation.Ids to sent the MessageContent to....
Represents an update of ChannelRepresentations.
A packet of a split serialized set of data.
uint? PayloadId
The ID of the full request to differentiate different chunkings.Nullable to prevent default value omi...
Class that deserializes chunked interop payloads.
ILogger< Chunker > Logger
The ILogger for the Chunker.
uint NextPayloadId
Gets a payload ID for use in a new ChunkSetInfo.
Constants used for communication with the DMAPI.
static readonly JsonSerializerSettings SerializerSettings
JsonSerializerSettings for use when communicating with the DMAPI.
const uint MaximumTopicRequestLength
The maximum length in bytes of a Byond.TopicSender.ITopicClient payload.
static readonly Version InteropVersion
The DMAPI InteropVersion being used.
const string TopicData
Parameter json is encoded in for topic requests.
Common base for interop parameters.
string AccessIdentifier
Used to identify and authenticate the DreamDaemon instance.
string? ErrorMessage
Any errors in the client's parameters.
string? Text
The message string.
TopicParameters for TopicCommandType.ReceiveChunk.
Parameters for a topic request.
static TopicParameters CreateInstanceRenamedTopicParameters(string newInstanceName)
Initializes a new instance of the TopicParameters class.
TopicCommandType? CommandType
The TopicCommandType.
ChunkData? Chunk
The ChunkData for a partial request.
bool IsPriority
Whether or not the TopicParameters constitute a priority request.
A response to a topic request.
Combines a Byond.TopicSender.TopicResponse with a TopicResponse.
TopicResponse? InteropResponse
The interop TopicResponse, if any.
Represents the result of trying to start a DD process.
async ValueTask InstanceRenamed(string newInstanceName, CancellationToken cancellationToken)
Called when the owning Instance is renamed.A ValueTask representing the running operation.
ValueTask< TopicResponse?> SendCommand(TopicParameters parameters, CancellationToken cancellationToken)
Sends a command to DreamDaemon through /world/Topic().A ValueTask<TResult> resulting in the TopicResp...
async ValueTask< BridgeResponse?> ProcessBridgeCommand(BridgeParameters parameters, CancellationToken cancellationToken)
Handle a set of bridge parameters .
readonly Byond.TopicSender.ITopicClient byondTopicSender
The Byond.TopicSender.ITopicClient for the SessionController.
string DumpFileExtension
The file extension to use for process dumps created from this session.
ApiValidationStatus apiValidationStatus
The ApiValidationStatus for the SessionController.
async ValueTask DisposeAsync()
readonly object synchronizationLock
lock object for port updates and disposed.
DateTimeOffset? LaunchTime
When the process was started.
void AdjustPriority(bool higher)
Set's the owned global::System.Diagnostics.Process.PriorityClass to a non-normal value.
async ValueTask< TopicResponse?> SendCommand(TopicParameters parameters, bool bypassLaunchResult, CancellationToken cancellationToken)
Sends a command to DreamDaemon through /world/Topic().
volatile uint rebootBridgeRequestsProcessing
The number of currently active calls to ProcessBridgeRequest(BridgeParameters, CancellationToken) fro...
readonly IDotnetDumpService dotnetDumpService
The IDotnetDumpService for the SessionController.
readonly Api.Models.Instance metadata
The Instance metadata.
Task OnReboot
A Task that completes when the server calls /world/TgsReboot().
bool DMApiAvailable
If the DMAPI may be used this session.
readonly TaskCompletionSource initialBridgeRequestTcs
The TaskCompletionSource that completes when DD makes it's first bridge request.
bool terminationWasIntentional
Backing field for overriding TerminationWasIntentional.
bool disposed
If the SessionController has been disposed.
void SuspendProcess()
Suspends the process.
void ResetRebootState()
Changes RebootState to RebootState.Normal without telling the DMAPI.
readonly IEngineExecutableLock engineLock
The IEngineExecutableLock for the SessionController.
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the SessionController.
async ValueTask< BridgeResponse?> ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken)
Handle a set of bridge parameters .A ValueTask<TResult> resulting in the BridgeResponse for the reque...
ReattachInformation ReattachInformation
The up to date Session.ReattachInformation.
volatile Task rebootGate
Backing field for RebootGate.
bool TerminationWasIntentional
If the DreamDaemon instance sent a.
readonly IEventConsumer eventConsumer
The IEventConsumer for the SessionController.
BridgeResponse BridgeError(string message)
Log and return a BridgeResponse for a given message .
bool released
If process should be kept alive instead.
readonly IChatManager chat
The IChatManager for the SessionController.
double MeasureProcessorTimeDelta()
Gets the estimated CPU usage fraction of the process based on the last time this was called....
readonly IChatTrackingContext chatTrackingContext
The IChatTrackingContext for the SessionController.
Task< int?> Lifetime
The Task<TResult> resulting in the exit code of the process or null if the process was detached.
readonly CancellationTokenSource sessionDurationCts
A CancellationTokenSource used for tasks that should not exceed the lifetime of the session.
ValueTask CreateDump(string outputFile, bool minidump, CancellationToken cancellationToken)
Create a dump file of the process.A ValueTask representing the running operation.
volatile TaskCompletionSource startupTcs
The TaskCompletionSource that completes when DD sends a valid startup bridge request.
async Task PostValidationShutdown(Task< bool > proceedTask)
Terminates the server after ten seconds if it does not exit.
void ResumeProcess()
Resumes the process.
SessionController(ReattachInformation reattachInformation, Api.Models.Instance metadata, IProcess process, IEngineExecutableLock engineLock, Byond.TopicSender.ITopicClient byondTopicSender, IChatTrackingContext chatTrackingContext, IBridgeRegistrar bridgeRegistrar, IChatManager chat, IAssemblyInformationProvider assemblyInformationProvider, IAsyncDelayer asyncDelayer, IDotnetDumpService dotnetDumpService, IEventConsumer eventConsumer, ILogger< SessionController > logger, Func< ValueTask > postLifetimeCallback, uint? startupTimeout, bool reattached, bool apiValidate)
Initializes a new instance of the SessionController class.
readonly bool apiValidationSession
If this session is meant to validate the presence of the DMAPI.
FifoSemaphore TopicSendSemaphore
The FifoSemaphore used to prevent concurrent calls into /world/Topic().
async ValueTask UpdateChannels(IEnumerable< ChannelRepresentation > newChannels, CancellationToken cancellationToken)
Called when newChannels are set.A ValueTask representing the running operation.
string GenerateQueryString(TopicParameters parameters, out string json)
Generates a Byond.TopicSender.ITopicClient query string for a given set of parameters .
void CheckDisposed()
Throws an ObjectDisposedException if DisposeAsync has been called.
readonly? IBridgeRegistration bridgeRegistration
The IBridgeRegistration for the SessionController.
long? MemoryUsage
Gets the process' memory usage in bytes.
async Task< LaunchResult > GetLaunchResult(IAssemblyInformationProvider assemblyInformationProvider, IAsyncDelayer asyncDelayer, uint? startupTimeout, bool reattached, bool apiValidate)
The Task<TResult> for LaunchResult.
IAsyncDisposable ReplaceDmbProvider(IDmbProvider dmbProvider)
Replace the IDmbProvider in use with a given newProvider , disposing the old one.An IAsyncDisposable ...
Task OnStartup
A Task that completes when the server calls /world/TgsNew().
bool ProcessingRebootBridgeRequest
If the ISessionController is currently processing a bridge request from TgsReboot().
ValueTask Release()
Releases the IProcess without terminating it. Also calls IDisposable.Dispose.A ValueTask representing...
volatile? Task postValidationShutdownTask
Task for shutting down the server if it is taking too long after validation.
volatile Task customEventProcessingTask
The Task representing calls to TriggerCustomEvent(CustomEventInvocation?).
Task OnPrime
A Task that completes when the server calls /world/TgsInitializationComplete().
async ValueTask< CombinedTopicResponse?> SendTopicRequest(TopicParameters parameters, CancellationToken cancellationToken)
Send a topic request for given parameters to DreamDaemon, chunking it if necessary.
volatile TaskCompletionSource rebootTcs
The TaskCompletionSource that completes when DD tells us about a reboot.
async ValueTask< CombinedTopicResponse?> SendRawTopic(string queryString, bool priority, CancellationToken cancellationToken)
Send a given queryString to DreamDaemon's /world/Topic.
volatile TaskCompletionSource primeTcs
The TaskCompletionSource that completes when DD tells us it's primed.
async ValueTask< bool > SetRebootState(RebootState newRebootState, CancellationToken cancellationToken)
Attempts to change the current RebootState to newRebootState .A ValueTask<TResult> resulting in true ...
Task RebootGate
A Task that must complete before a TgsReboot() bridge request can complete.
Version? DMApiVersion
The DMAPI Version.
readonly IProcess process
The IProcess for the SessionController.
BridgeResponse TriggerCustomEvent(CustomEventInvocation? invocation)
Trigger a custom event from a given invocation .
A first-in first-out async semaphore.
async ValueTask< SemaphoreSlimContext > Lock(CancellationToken cancellationToken)
Locks the FifoSemaphore.
Helpers for manipulating the Serilog.Context.LogContext.
const string InstanceIdContextProperty
The Serilog.Context.LogContext property name for Models.Instance Api.Models.EntityId....
Notifyee of when ChannelRepresentations in a IChatTrackingContext are updated.
For managing connected chat services.
void QueueMessage(MessageContent message, IEnumerable< ulong > channelIds)
Queue a chat message to a given set of channelIds .
Represents a tracking of dynamic chat json files.
bool Active
If the CustomCommands should be used.
void SetChannelSink(IChannelSink channelSink)
Sets the channelSink for the IChatTrackingContext.
Provides absolute paths to the latest compiled .dmbs.
void KeepAlive()
Disposing the IDmbProvider won't cause a cleanup of the working directory.
EngineVersion EngineVersion
The Api.Models.EngineVersion used to build the .dmb.
string Directory
The primary game directory.
Models.CompileJob CompileJob
The CompileJob of the .dmb.
Represents usage of the two primary BYOND server executables.
void DoNotDeleteThisSession()
Call if, during a detach, this version should not be deleted.
bool UseDotnetDump
If dotnet-dump should be used to create process dumps for this installation.
ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken)
Kills a given engine server process .
Consumes EventTypes and takes the appropriate actions.
ValueTask? HandleCustomEvent(string eventName, IEnumerable< string?> parameters, CancellationToken cancellationToken)
Handles a given custom event.
Registers IBridgeHandlers.
IBridgeRegistration RegisterHandler(IBridgeHandler bridgeHandler)
Register a given bridgeHandler .
Represents a registration of an interop session.
Handles communication with a DreamDaemon IProcess.
Service for managing the dotnet-dump installation.
ValueTask Dump(IProcess process, string outputFile, bool minidump, CancellationToken cancellationToken)
Attempt to dump a given process .
void SuspendProcess()
Suspends the process.
void ResumeProcess()
Resumes the process.
void AdjustPriority(bool higher)
Set's the owned global::System.Diagnostics.Process.PriorityClass to a non-normal value.
long? MemoryUsage
Gets the process' memory usage in bytes.
double MeasureProcessorTimeDelta()
Gets the estimated CPU usage fraction of the process based on the last time this was called.
DateTimeOffset? LaunchTime
When the process was started.
ValueTask CreateDump(string outputFile, bool minidump, CancellationToken cancellationToken)
Create a dump file of the process.
Task< int?> Lifetime
The Task<TResult> resulting in the exit code of the process or null if the process was detached.
Abstraction over a global::System.Diagnostics.Process.
Task Startup
The Task representing the time until the IProcess becomes "idle".
void Terminate()
Asycnhronously terminates the process.
For waiting asynchronously.
ValueTask Delay(TimeSpan timeSpan, CancellationToken cancellationToken)
Create a Task that completes after a given timeSpan .
DreamDaemonSecurity
DreamDaemon's security level.
EngineType
The type of engine the codebase is using.
@ Byond
Build your own net dream.
BridgeCommandType
Represents the BridgeParameters.CommandType.
@ Chunk
DreamDaemon attempting to send a longer bridge message.
RebootState
Represents the action to take when /world/Reboot() is called.
ApiValidationStatus
Status of DMAPI validation.