mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Implement IServer. Add some missing things to IInstance
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
<Compile Include="..\AssemblyInfo.global.cs" />
|
||||
<Compile Include="Components\Service.cs" />
|
||||
<Compile Include="Components\Interop.cs" />
|
||||
<Compile Include="Wrappers\Server.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="tgs.ico" />
|
||||
|
||||
@@ -7,6 +7,11 @@ namespace TGS.Interface.Wrappers
|
||||
/// </summary>
|
||||
public interface IInstance : ITGInstance
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="InstanceMetadata"/> for the <see cref="IInstance"/>
|
||||
/// </summary>
|
||||
InstanceMetadata Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITGAdministration"/> component
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using TGS.Interface.Components;
|
||||
using System.Linq;
|
||||
using TGS.Interface.Components;
|
||||
|
||||
namespace TGS.Interface.Wrappers
|
||||
{
|
||||
@@ -12,53 +13,65 @@ namespace TGS.Interface.Wrappers
|
||||
/// <summary>
|
||||
/// The name of the <see cref="IInstance"/>
|
||||
/// </summary>
|
||||
readonly string instanceName;
|
||||
InstanceMetadata metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Construct an <see cref="Instance"/>
|
||||
/// </summary>
|
||||
/// <param name="_serverInterface">The <see cref="ServerInterface"/> to use</param>
|
||||
/// <param name="_instanceName">The <see cref="IInstance"/> name to use</param>
|
||||
public Instance(ServerInterface _serverInterface, string _instanceName)
|
||||
/// <param name="_metadata">The <see cref="InstanceMetadata"/> for the <see cref="IInstance"/></param>
|
||||
public Instance(ServerInterface _serverInterface, InstanceMetadata _metadata)
|
||||
{
|
||||
serverInterface = _serverInterface;
|
||||
instanceName = _instanceName;
|
||||
metadata = _metadata;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGAdministration Administration => serverInterface.GetComponent<ITGAdministration>(instanceName);
|
||||
public InstanceMetadata Metadata
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!metadata.Enabled)
|
||||
//metadata needs populating
|
||||
metadata = serverInterface.GetComponent<ITGLanding>(null).ListInstances().Where(x => x.Name == metadata.Name).First();
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGByond Byond => serverInterface.GetComponent<ITGByond>(instanceName);
|
||||
public ITGAdministration Administration => serverInterface.GetComponent<ITGAdministration>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGChat Chat => serverInterface.GetComponent<ITGChat>(instanceName);
|
||||
public ITGByond Byond => serverInterface.GetComponent<ITGByond>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGCompiler Compiler => serverInterface.GetComponent<ITGCompiler>(instanceName);
|
||||
public ITGChat Chat => serverInterface.GetComponent<ITGChat>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGConfig Config => serverInterface.GetComponent<ITGConfig>(instanceName);
|
||||
public ITGCompiler Compiler => serverInterface.GetComponent<ITGCompiler>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGDreamDaemon DreamDaemon => serverInterface.GetComponent<ITGDreamDaemon>(instanceName);
|
||||
public ITGConfig Config => serverInterface.GetComponent<ITGConfig>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGInterop Interop => serverInterface.GetComponent<ITGInterop>(instanceName);
|
||||
public ITGDreamDaemon DreamDaemon => serverInterface.GetComponent<ITGDreamDaemon>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGRepository Repository => serverInterface.GetComponent<ITGRepository>(instanceName);
|
||||
public ITGInterop Interop => serverInterface.GetComponent<ITGInterop>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGRepository Repository => serverInterface.GetComponent<ITGRepository>(metadata.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ServerDirectory()
|
||||
{
|
||||
return serverInterface.GetComponent<ITGInstance>(instanceName).ServerDirectory();
|
||||
return serverInterface.GetComponent<ITGInstance>(metadata.Name).ServerDirectory();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Version()
|
||||
{
|
||||
return serverInterface.GetComponent<ITGInstance>(instanceName).Version();
|
||||
return serverInterface.GetComponent<ITGInstance>(metadata.Name).Version();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TGS.Interface.Components;
|
||||
|
||||
namespace TGS.Interface.Wrappers
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class Server : IServer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public Version Version => serverInterface.ServerVersion;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IInstance> Instances { get
|
||||
{
|
||||
lock (this)
|
||||
if(knownInstances == null)
|
||||
knownInstances = serverInterface.GetComponent<ITGLanding>().ListInstances();
|
||||
foreach(var I in knownInstances)
|
||||
yield return new Instance(serverInterface, I);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITGInstanceManager InstanceManager => serverInterface.GetComponent<ITGInstanceManager>();
|
||||
|
||||
/// <summary>
|
||||
/// The backing <see cref="ServerInterface"/>
|
||||
/// </summary>
|
||||
readonly ServerInterface serverInterface;
|
||||
|
||||
/// <summary>
|
||||
/// Result of a call to <see cref="ITGLanding.ListInstances"/>
|
||||
/// </summary>
|
||||
IList<InstanceMetadata> knownInstances;
|
||||
|
||||
/// <summary>
|
||||
/// Construct an <see cref="Server"/>
|
||||
/// </summary>
|
||||
/// <param name="_serverInterface">The <see cref="ServerInterface"/> to use</param>
|
||||
public Server(ServerInterface _serverInterface)
|
||||
{
|
||||
serverInterface = _serverInterface;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IInstance GetInstance(string name)
|
||||
{
|
||||
return new Instance(serverInterface, new InstanceMetadata { Name = name, Enabled = false });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PrepareForUpdate()
|
||||
{
|
||||
serverInterface.GetComponent<ITGSService>().PrepareForUpdate();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string PythonPath()
|
||||
{
|
||||
return serverInterface.GetComponent<ITGSService>().PythonPath();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort RemoteAccessPort()
|
||||
{
|
||||
return serverInterface.GetComponent<ITGSService>().RemoteAccessPort();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SetPythonPath(string path)
|
||||
{
|
||||
return serverInterface.GetComponent<ITGSService>().SetPythonPath(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string SetRemoteAccessPort(ushort port)
|
||||
{
|
||||
return serverInterface.GetComponent<ITGSService>().SetRemoteAccessPort(port);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
string ITGSService.Version()
|
||||
{
|
||||
return serverInterface.GetComponent<ITGSService>().Version();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user