Massive sanity reorganization of project structure

Overall:
- Removed all 'TG' prefixes on classes and enums
Service:
- TGStationServer => ServerInstance
- TGServerService => Service
- Moved all ServerInstance partial classes to a subfolder
- Moved ChatProvider classes, delegate, and interface to a namespace
- Moved EventID and ChatMessageType to their own .cs files
- Moved SanitizeTopicString to Program
- ServerService.cs => Service.cs
- Fixed ProjectInstaller being in it's own namespace instead of
TGServerService
Interface:
- Moved ExitCode enum to Command class
- Moved all components to a namespace
- Moved all component enums to Enumerations.cs
- DDInteropCallHolder => DreamDaemonBridge
- Move PullRequestInfo and DreamDaemonBridge to their own .cs files
- Changes the type of ChannelFactory cache from Dictionary<Type,
ChannelFactory> to IDictionary<Type, ChannelFactory>
This commit is contained in:
Cyberboss
2017-10-20 14:00:09 -04:00
parent 7b8fa03f5d
commit 3137be7abb
58 changed files with 3274 additions and 3212 deletions
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
+12 -11
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
@@ -26,12 +27,12 @@ namespace TGCommandLine
}
protected override ExitCode Run(IList<string> parameters)
{
var type = TGByondVersion.Installed;
var type = ByondVersion.Installed;
if (parameters.Count > 0)
if (parameters[0].ToLower() == "--staged")
type = TGByondVersion.Staged;
type = ByondVersion.Staged;
else if (parameters[0].ToLower() == "--latest")
type = TGByondVersion.Latest;
type = ByondVersion.Latest;
OutputProc(Server.GetComponent<ITGByond>().GetVersion(type) ?? "Unistalled");
return ExitCode.Normal;
}
@@ -57,22 +58,22 @@ namespace TGCommandLine
{
switch (Server.GetComponent<ITGByond>().CurrentStatus())
{
case TGByondStatus.Downloading:
case ByondStatus.Downloading:
OutputProc("Downloading update...");
break;
case TGByondStatus.Idle:
case ByondStatus.Idle:
OutputProc("Updater Idle");
break;
case TGByondStatus.Staged:
case ByondStatus.Staged:
OutputProc("Update staged and awaiting server restart");
break;
case TGByondStatus.Staging:
case ByondStatus.Staging:
OutputProc("Staging update...");
break;
case TGByondStatus.Starting:
case ByondStatus.Starting:
OutputProc("Starting update...");
break;
case TGByondStatus.Updating:
case ByondStatus.Updating:
OutputProc("Applying update...");
break;
default:
@@ -117,13 +118,13 @@ namespace TGCommandLine
}
var stat = BYOND.CurrentStatus();
while (stat != TGByondStatus.Idle && stat != TGByondStatus.Staged)
while (stat != ByondStatus.Idle && stat != ByondStatus.Staged)
{
Thread.Sleep(100);
stat = BYOND.CurrentStatus();
}
var res = BYOND.GetError();
OutputProc(res ?? (stat == TGByondStatus.Staged ? "Update staged and will apply next DD reboot" : "Update finished"));
OutputProc(res ?? (stat == ByondStatus.Staged ? "Update staged and will apply next DD reboot" : "Update finished"));
return res == null ? ExitCode.Normal : ExitCode.ServerError;
}
public override string GetArgumentString()
+29 -28
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
@@ -9,7 +10,7 @@ namespace TGCommandLine
public IRCCommand()
{
Keyword = "irc";
Children = new Command[] { new IRCNickCommand(), new IRCAuthCommand(), new IRCDisableAuthCommand(), new IRCServerCommand(), new ChatJoinCommand(TGChatProvider.IRC), new ChatPartCommand(TGChatProvider.IRC), new ChatListAdminsCommand(TGChatProvider.IRC), new ChatReconnectCommand(TGChatProvider.IRC), new ChatAddminCommand(TGChatProvider.IRC), new ChatDeadminCommand(TGChatProvider.IRC), new ChatEnableCommand(TGChatProvider.IRC), new ChatDisableCommand(TGChatProvider.IRC), new ChatStatusCommand(TGChatProvider.IRC), new IRCAuthModeCommand(), new IRCAuthLevelCommand() };
Children = new Command[] { new IRCNickCommand(), new IRCAuthCommand(), new IRCDisableAuthCommand(), new IRCServerCommand(), new ChatJoinCommand(ChatProvider.IRC), new ChatPartCommand(ChatProvider.IRC), new ChatListAdminsCommand(ChatProvider.IRC), new ChatReconnectCommand(ChatProvider.IRC), new ChatAddminCommand(ChatProvider.IRC), new ChatDeadminCommand(ChatProvider.IRC), new ChatEnableCommand(ChatProvider.IRC), new ChatDisableCommand(ChatProvider.IRC), new ChatStatusCommand(ChatProvider.IRC), new IRCAuthModeCommand(), new IRCAuthLevelCommand() };
}
public override string GetHelpText()
{
@@ -21,7 +22,7 @@ namespace TGCommandLine
public DiscordCommand()
{
Keyword = "discord";
Children = new Command[] { new DiscordSetTokenCommand(), new ChatJoinCommand(TGChatProvider.Discord), new ChatPartCommand(TGChatProvider.Discord), new ChatListAdminsCommand(TGChatProvider.Discord), new ChatReconnectCommand(TGChatProvider.Discord), new ChatAddminCommand(TGChatProvider.Discord), new ChatDeadminCommand(TGChatProvider.Discord), new ChatEnableCommand(TGChatProvider.Discord), new ChatDisableCommand(TGChatProvider.Discord), new ChatStatusCommand(TGChatProvider.Discord) , new DiscordAuthModeCommand() };
Children = new Command[] { new DiscordSetTokenCommand(), new ChatJoinCommand(ChatProvider.Discord), new ChatPartCommand(ChatProvider.Discord), new ChatListAdminsCommand(ChatProvider.Discord), new ChatReconnectCommand(ChatProvider.Discord), new ChatAddminCommand(ChatProvider.Discord), new ChatDeadminCommand(ChatProvider.Discord), new ChatEnableCommand(ChatProvider.Discord), new ChatDisableCommand(ChatProvider.Discord), new ChatStatusCommand(ChatProvider.Discord) , new DiscordAuthModeCommand() };
}
public override string GetHelpText()
{
@@ -48,7 +49,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var Chat = Server.GetComponent<ITGChat>();
Chat.SetProviderInfo(new TGIRCSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.IRC])
Chat.SetProviderInfo(new IRCSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.IRC])
{
Nickname = parameters[0],
});
@@ -59,7 +60,7 @@ namespace TGCommandLine
class ChatJoinCommand : Command
{
readonly int providerIndex;
public ChatJoinCommand(TGChatProvider pI)
public ChatJoinCommand(ChatProvider pI)
{
Keyword = "join";
RequiredParameters = 2;
@@ -138,7 +139,7 @@ namespace TGCommandLine
class ChatPartCommand : Command
{
readonly int providerIndex;
public ChatPartCommand(TGChatProvider pI)
public ChatPartCommand(ChatProvider pI)
{
Keyword = "part";
RequiredParameters = 2;
@@ -178,7 +179,7 @@ namespace TGCommandLine
return ExitCode.BadCommand;
}
var lowerParam = parameters[0].ToLower();
if ((TGChatProvider)providerIndex == TGChatProvider.IRC && lowerParam[0] != '#')
if ((ChatProvider)providerIndex == ChatProvider.IRC && lowerParam[0] != '#')
lowerParam = "#" + lowerParam;
channels.Remove(lowerParam);
switch (parameters[1].ToLower())
@@ -208,7 +209,7 @@ namespace TGCommandLine
class ChatListAdminsCommand : Command
{
readonly int providerIndex;
public ChatListAdminsCommand(TGChatProvider pI)
public ChatListAdminsCommand(ChatProvider pI)
{
Keyword = "list-admins";
providerIndex = (int)pI;
@@ -223,15 +224,15 @@ namespace TGCommandLine
{
var info = Server.GetComponent<ITGChat>().ProviderInfos()[providerIndex];
string authType;
switch ((TGChatProvider)providerIndex)
switch ((ChatProvider)providerIndex)
{
case TGChatProvider.IRC:
case ChatProvider.IRC:
if (info.AdminsAreSpecial)
authType = "Mode:";
else
authType = "Nicknames:";
break;
case TGChatProvider.Discord:
case ChatProvider.Discord:
if (info.AdminsAreSpecial)
authType = "Role IDs:";
else
@@ -242,8 +243,8 @@ namespace TGCommandLine
return ExitCode.ServerError;
}
OutputProc("Authorized " + authType);
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
switch(new TGIRCSetupInfo(info).AuthLevel)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
switch(new IRCSetupInfo(info).AuthLevel)
{
case IRCMode.Voice:
OutputProc("+");
@@ -266,8 +267,8 @@ namespace TGCommandLine
}
class ChatReconnectCommand : Command
{
readonly TGChatProvider providerIndex;
public ChatReconnectCommand(TGChatProvider pI)
readonly ChatProvider providerIndex;
public ChatReconnectCommand(ChatProvider pI)
{
Keyword = "reconnect";
providerIndex = pI;
@@ -292,7 +293,7 @@ namespace TGCommandLine
class ChatAddminCommand : Command
{
readonly int providerIndex;
public ChatAddminCommand(TGChatProvider pI)
public ChatAddminCommand(ChatProvider pI)
{
Keyword = "addmin";
RequiredParameters = 1;
@@ -313,7 +314,7 @@ namespace TGCommandLine
var info = IRC.ProviderInfos()[providerIndex];
var newmin = parameters[0].ToLower();
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
{
OutputProc("Invalid auth mode for this command!");
return ExitCode.BadCommand;
@@ -355,7 +356,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = IRC.ProviderInfos()[(int)TGChatProvider.IRC];
var info = IRC.ProviderInfos()[(int)ChatProvider.IRC];
var lowerparam = parameters[0].ToLower();
if (lowerparam == "channel-mode")
info.AdminsAreSpecial = true;
@@ -394,7 +395,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = IRC.ProviderInfos()[(int)TGChatProvider.Discord];
var info = IRC.ProviderInfos()[(int)ChatProvider.Discord];
var lowerparam = parameters[0].ToLower();
if (lowerparam == "role-id")
info.AdminsAreSpecial = true;
@@ -433,7 +434,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
var info = new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC]);
var info = new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC]);
switch (parameters[0])
{
case "+":
@@ -465,7 +466,7 @@ namespace TGCommandLine
class ChatDeadminCommand : Command
{
readonly int providerIndex;
public ChatDeadminCommand(TGChatProvider pI)
public ChatDeadminCommand(ChatProvider pI)
{
Keyword = "deadmin";
RequiredParameters = 1;
@@ -485,7 +486,7 @@ namespace TGCommandLine
var info = IRC.ProviderInfos()[providerIndex];
var newmin = parameters[0].ToLower();
if (info.AdminsAreSpecial && (TGChatProvider)providerIndex == TGChatProvider.IRC)
if (info.AdminsAreSpecial && (ChatProvider)providerIndex == ChatProvider.IRC)
{
OutputProc("Invalid auth mode for this command!");
return ExitCode.BadCommand;
@@ -529,7 +530,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
IRC.SetProviderInfo(new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC])
IRC.SetProviderInfo(new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC])
{
AuthTarget = parameters[0],
AuthMessage = parameters[1]
@@ -551,7 +552,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var IRC = Server.GetComponent<ITGChat>();
IRC.SetProviderInfo(new TGIRCSetupInfo(IRC.ProviderInfos()[(int)TGChatProvider.IRC])
IRC.SetProviderInfo(new IRCSetupInfo(IRC.ProviderInfos()[(int)ChatProvider.IRC])
{
AuthTarget = null,
AuthMessage = null,
@@ -563,7 +564,7 @@ namespace TGCommandLine
class ChatStatusCommand : Command
{
readonly int providerIndex;
public ChatStatusCommand(TGChatProvider pI)
public ChatStatusCommand(ChatProvider pI)
{
Keyword = "status";
providerIndex = (int)pI;
@@ -596,7 +597,7 @@ namespace TGCommandLine
class ChatEnableCommand : Command
{
readonly int providerIndex;
public ChatEnableCommand(TGChatProvider pI)
public ChatEnableCommand(ChatProvider pI)
{
Keyword = "enable";
providerIndex = (int)pI;
@@ -624,7 +625,7 @@ namespace TGCommandLine
class ChatDisableCommand : Command
{
readonly int providerIndex;
public ChatDisableCommand(TGChatProvider pI)
public ChatDisableCommand(ChatProvider pI)
{
Keyword = "disable";
providerIndex = (int)pI;
@@ -675,7 +676,7 @@ namespace TGCommandLine
return ExitCode.BadCommand;
}
var Chat = Server.GetComponent<ITGChat>();
var PI = new TGIRCSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.IRC])
var PI = new IRCSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.IRC])
{
URL = splits[0]
};
@@ -713,7 +714,7 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
var Chat = Server.GetComponent<ITGChat>();
var res = Chat.SetProviderInfo(new TGDiscordSetupInfo(Chat.ProviderInfos()[(int)TGChatProvider.Discord]) { BotToken = parameters[0] });
var res = Chat.SetProviderInfo(new DiscordSetupInfo(Chat.ProviderInfos()[(int)ChatProvider.Discord]) { BotToken = parameters[0] });
OutputProc(res ?? "Success");
return res == null ? ExitCode.Normal : ExitCode.ServerError;
}
+1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
+7 -6
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
@@ -84,7 +85,7 @@ namespace TGCommandLine
var DD = Server.GetComponent<ITGDreamDaemon>();
if (parameters.Count > 0 && parameters[0].ToLower() == "--graceful")
{
if (DD.DaemonStatus() != TGDreamDaemonStatus.Online)
if (DD.DaemonStatus() != DreamDaemonStatus.Online)
{
OutputProc("Error: The game is not currently running!");
return ExitCode.ServerError;
@@ -113,7 +114,7 @@ namespace TGCommandLine
var DD = Server.GetComponent<ITGDreamDaemon>();
if (parameters.Count > 0 && parameters[0].ToLower() == "--graceful")
{
if (DD.DaemonStatus() != TGDreamDaemonStatus.Online)
if (DD.DaemonStatus() != DreamDaemonStatus.Online)
{
OutputProc("Error: The game is not currently running!");
return ExitCode.ServerError;
@@ -279,19 +280,19 @@ namespace TGCommandLine
protected override ExitCode Run(IList<string> parameters)
{
TGDreamDaemonSecurity sec;
DreamDaemonSecurity sec;
switch (parameters[0].ToLower())
{
case "safe":
sec = TGDreamDaemonSecurity.Safe;
sec = DreamDaemonSecurity.Safe;
break;
case "ultra":
case "ultrasafe":
sec = TGDreamDaemonSecurity.Ultrasafe;
sec = DreamDaemonSecurity.Ultrasafe;
break;
case "trust":
case "trusted":
sec = TGDreamDaemonSecurity.Trusted;
sec = DreamDaemonSecurity.Trusted;
break;
default:
OutputProc("Invalid security word!");
+12 -11
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
@@ -29,13 +30,13 @@ namespace TGCommandLine
{
var DM = Server.GetComponent<ITGCompiler>();
var stat = DM.GetStatus();
if (stat != TGCompilerStatus.Initialized)
if (stat != CompilerStatus.Initialized)
{
OutputProc("Error: Compiler is " + ((stat == TGCompilerStatus.Uninitialized) ? "unintialized!" : "busy with another task!"));
OutputProc("Error: Compiler is " + ((stat == CompilerStatus.Uninitialized) ? "unintialized!" : "busy with another task!"));
return ExitCode.ServerError;
}
if (Server.GetComponent<ITGByond>().GetVersion(TGByondVersion.Installed) == null)
if (Server.GetComponent<ITGByond>().GetVersion(ByondVersion.Installed) == null)
{
Console.Write("Error: BYOND is not installed!");
return ExitCode.ServerError;
@@ -55,7 +56,7 @@ namespace TGCommandLine
do
{
Thread.Sleep(1000);
} while (DM.GetStatus() == TGCompilerStatus.Compiling);
} while (DM.GetStatus() == CompilerStatus.Compiling);
var res = DM.CompileError();
OutputProc(res ?? "Compilation successful");
if (res != null)
@@ -95,17 +96,17 @@ namespace TGCommandLine
Console.Write("Compilier is currently: ");
switch (DM.GetStatus())
{
case TGCompilerStatus.Compiling:
case CompilerStatus.Compiling:
OutputProc("Compiling...");
break;
case TGCompilerStatus.Initialized:
case CompilerStatus.Initialized:
OutputProc("Idle");
ShowError();
break;
case TGCompilerStatus.Initializing:
case CompilerStatus.Initializing:
OutputProc("Setting up...");
break;
case TGCompilerStatus.Uninitialized:
case CompilerStatus.Uninitialized:
OutputProc("Uninitialized");
ShowError();
break;
@@ -167,9 +168,9 @@ namespace TGCommandLine
{
var DM = Server.GetComponent<ITGCompiler>();
var stat = DM.GetStatus();
if (stat == TGCompilerStatus.Compiling || stat == TGCompilerStatus.Initializing)
if (stat == CompilerStatus.Compiling || stat == CompilerStatus.Initializing)
{
OutputProc("Error: Compiler is " + ((stat == TGCompilerStatus.Initializing) ? "already initialized!" : " already running!"));
OutputProc("Error: Compiler is " + ((stat == CompilerStatus.Initializing) ? "already initialized!" : " already running!"));
return ExitCode.ServerError;
}
if (!DM.Initialize())
@@ -186,7 +187,7 @@ namespace TGCommandLine
do
{
Thread.Sleep(1000);
} while (DM.GetStatus() == TGCompilerStatus.Initializing);
} while (DM.GetStatus() == CompilerStatus.Initializing);
var res = DM.CompileError();
OutputProc(res ?? "Initialization successful");
if (res != null)
+8 -7
View File
@@ -2,13 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
class Program
{
static ExitCode RunCommandLine(IList<string> argsAsList)
static Command.ExitCode RunCommandLine(IList<string> argsAsList)
{
//first lookup the connection string
bool badConnectionString = false;
@@ -58,7 +59,7 @@ namespace TGCommandLine
if (badConnectionString)
{
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address:port");
return ExitCode.BadCommand;
return Command.ExitCode.BadCommand;
}
var res = Server.VerifyConnection();
@@ -66,13 +67,13 @@ namespace TGCommandLine
{
Console.WriteLine("Unable to connect to service: " + res);
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address:port");
return ExitCode.ConnectionError;
return Command.ExitCode.ConnectionError;
}
if (!Server.Authenticate())
{
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized!");
return ExitCode.ConnectionError;
return Command.ExitCode.ConnectionError;
}
if (!SentVMMWarning && Server.VersionMismatch(out string error))
@@ -88,7 +89,7 @@ namespace TGCommandLine
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
return ExitCode.ConnectionError;
return Command.ExitCode.ConnectionError;
};
}
public static string ReadLineSecure()
@@ -208,11 +209,11 @@ namespace TGCommandLine
break;
case "quit":
case "exit":
return (int)ExitCode.Normal;
return (int)Command.ExitCode.Normal;
#if DEBUG
case "debug-upgrade":
Server.GetComponent<ITGSService>().PrepareForUpdate();
return (int)ExitCode.Normal;
return (int)Command.ExitCode.Normal;
#endif
default:
//linq voodoo to get quoted strings
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TGServiceInterface;
using TGServiceInterface.Components;
namespace TGCommandLine
{