|
|
@@ -19,15 +19,15 @@ namespace TBConsole |
|
|
|
public override void OnApplicationStart() |
|
|
|
{ |
|
|
|
TechbloxModdingAPI.Main.Init(); |
|
|
|
_server = new WebServer(CommandReceived); |
|
|
|
_server = new WebServer(CommandReceived, GetCommandList); |
|
|
|
_server.Start(); |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<string> CommandReceived(string command) |
|
|
|
private string CommandReceived(string command) |
|
|
|
{ |
|
|
|
if (_logHandler == null) |
|
|
|
Debug.unityLogger.logHandler = _logHandler = new UnityLogHandler(Debug.unityLogger.logHandler); |
|
|
|
var logTask = _logHandler.CollectLogMessages(); |
|
|
|
_logHandler.StartCollectingLogMessages(); |
|
|
|
bool inString = false; |
|
|
|
var cmdparts = new List<string>(); |
|
|
|
command = command.Trim(); |
|
|
@@ -62,10 +62,16 @@ namespace TBConsole |
|
|
|
return "Too many arguments! Maximum for default commands is 3"; |
|
|
|
} |
|
|
|
|
|
|
|
string result = await logTask; |
|
|
|
string result = _logHandler.FinishCollectingLogMessages(); |
|
|
|
return $"Got it: {command}\n{result}"; |
|
|
|
} |
|
|
|
|
|
|
|
public string GetCommandList() |
|
|
|
{ |
|
|
|
return ExistingCommands.GetCommandNamesAndDescriptions() |
|
|
|
.Select(command => command.Name + " - " + command.Description).Aggregate((a, b) => a + "\n" + b); |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnApplicationQuit() |
|
|
|
{ |
|
|
|
_server.Stop(); |
|
|
@@ -75,7 +81,7 @@ namespace TBConsole |
|
|
|
public static void Main(string[] args) |
|
|
|
{ |
|
|
|
var mod = new TBConsoleMod(); |
|
|
|
mod._server = new WebServer(mod.CommandReceived); |
|
|
|
mod._server = new WebServer(mod.CommandReceived, mod.GetCommandList); |
|
|
|
mod._server.Start(); |
|
|
|
Console.ReadLine(); |
|
|
|
} |
|
|
|