diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 8b3cf488..13fd0a20 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.3.0.0903")] -[assembly: AssemblyFileVersion("3.3.0.0903")] +[assembly: AssemblyVersion("3.3.0.0904")] +[assembly: AssemblyFileVersion("3.3.0.0904")] diff --git a/TShockAPI/RconHandler.cs b/TShockAPI/RconHandler.cs index ec34f563..d693e266 100644 --- a/TShockAPI/RconHandler.cs +++ b/TShockAPI/RconHandler.cs @@ -38,13 +38,30 @@ namespace TShockAPI public static string Response = ""; private static bool Started; private static UdpClient listener; + private static Thread startThread; + private static Thread heartbeat; + private static Thread listen; + + public static void ShutdownAllThreads() + { + if (Started) + { + startThread.Abort(); + heartbeat.Abort(); + listen.Abort(); + Started = false; + } + } public static void StartThread() { if (!Started) { - (new Thread(Start)).Start(); - (new Thread(SendHeartbeat)).Start(); + startThread = new Thread(Start); + startThread.Start(); + + heartbeat = new Thread(SendHeartbeat); + heartbeat.Start(); } Started = true; } @@ -57,7 +74,7 @@ namespace TShockAPI Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}", ListenPort, Password)); - Thread listen = new Thread(Listener); + listen = new Thread(Listener); listen.Start(); while (true) { @@ -161,8 +178,8 @@ namespace TShockAPI } else { - response = "Bad rconpassword.\n"; - Log.ConsoleInfo("Bad rconpassword from " + EP); + response = "Bad rcon password.\n"; + Log.ConsoleInfo("Bad rcon password from " + EP); } } else @@ -170,7 +187,7 @@ namespace TShockAPI } else { - response = "No rconpassword set on the server.\n"; + response = "No rcon password set on the server.\n"; Log.Info("No password for rcon set"); } } @@ -328,7 +345,7 @@ namespace TShockAPI { if ((DateTime.UtcNow - LastHeartbeat).Seconds >= 30) { - var packet = ConstructPacket("heartbeat TERRARIA", false); + var packet = ConstructPacket("heartbeat TerrariaShock", false); if (listener == null) try { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 1b06aaef..8d8e96f0 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -190,7 +190,7 @@ namespace TShockAPI GetDataHandlers.InitGetDataHandler(); Commands.InitCommands(); - //RconHandler.StartThread(); + RconHandler.StartThread(); if (Config.BufferPackets) PacketBuffer = new PacketBufferer(); @@ -226,6 +226,7 @@ namespace TShockAPI Console.WriteLine("Thanks for using TShock! Process ID file is now being destroyed."); File.Delete(Path.Combine(SavePath, "tshock.pid")); } + RconHandler.ShutdownAllThreads(); } ///