mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 08:00:19 +01:00
Merge upstream (wew, thats a big one)
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.ServiceModel;
|
||||
using TGServiceInterface.Components;
|
||||
|
||||
namespace TGServerService
|
||||
{
|
||||
//I know the fact that this is one massive partial class is gonna trigger everyone
|
||||
//There really was no other succinct way to do it (<= He's lying through his teeth, don't listen to him)
|
||||
|
||||
//this line basically says take one instance of the service, use it multithreaded for requests, and never delete it
|
||||
|
||||
/// <summary>
|
||||
/// The class which holds all interface components. There are no safeguards for call race conditions so these must be guarded against internally
|
||||
/// </summary>
|
||||
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
|
||||
sealed partial class ServerInstance : IDisposable, ITGConnectivity
|
||||
{
|
||||
/// <summary>
|
||||
/// The configuration settings for the instance
|
||||
/// </summary>
|
||||
public readonly InstanceConfig Config;
|
||||
/// <summary>
|
||||
/// Constructs and a <see cref="ServerInstance"/>
|
||||
/// </summary>
|
||||
public ServerInstance(InstanceConfig config)
|
||||
{
|
||||
Config = config;
|
||||
FindTheDroidsWereLookingFor();
|
||||
InitEventHandlers();
|
||||
InitChat();
|
||||
InitRepo();
|
||||
InitByond();
|
||||
InitCompiler();
|
||||
InitDreamDaemon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up the <see cref="ServerInstance"/>
|
||||
/// </summary>
|
||||
void RunDisposals()
|
||||
{
|
||||
DisposeDreamDaemon();
|
||||
DisposeCompiler();
|
||||
DisposeByond();
|
||||
DisposeRepo();
|
||||
DisposeChat();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Version()
|
||||
{
|
||||
return Service.VersionString;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void VerifyConnection() { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Reattach(bool silent)
|
||||
{
|
||||
Config.ReattachRequired = true;
|
||||
if(!silent)
|
||||
SendMessage("SERVICE: Update started...", MessageType.DeveloperInfo);
|
||||
}
|
||||
|
||||
//mostly generated code with a call to RunDisposals()
|
||||
//you don't need to open this
|
||||
#region IDisposable Support
|
||||
/// <summary>
|
||||
/// To detect redundant <see cref="Dispose()"/> calls
|
||||
/// </summary>
|
||||
private bool disposedValue = false;
|
||||
|
||||
/// <summary>
|
||||
/// Implements the <see cref="IDisposable"/> pattern. Calls <see cref="RunDisposals"/>
|
||||
/// </summary>
|
||||
/// <param name="disposing"><see langword="true"/> if <see cref="Dispose()"/> was called manually, <see langword="false"/> if it was from the finalizer</param>
|
||||
void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
RunDisposals();
|
||||
// TODO: dispose managed state (managed objects).
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
|
||||
// TODO: set large fields to null.
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
|
||||
// ~TGStationServer() {
|
||||
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
// Dispose(false);
|
||||
// }
|
||||
|
||||
// This code added to correctly implement the disposable pattern.
|
||||
/// <summary>
|
||||
/// Implements the <see cref="IDisposable"/> pattern
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalizer is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user