Enabled RCON.
This commit is contained in:
parent
7b23669e2f
commit
5939c3256a
3 changed files with 28 additions and 10 deletions
|
|
@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.3.0.0903")]
|
[assembly: AssemblyVersion("3.3.0.0904")]
|
||||||
[assembly: AssemblyFileVersion("3.3.0.0903")]
|
[assembly: AssemblyFileVersion("3.3.0.0904")]
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,30 @@ namespace TShockAPI
|
||||||
public static string Response = "";
|
public static string Response = "";
|
||||||
private static bool Started;
|
private static bool Started;
|
||||||
private static UdpClient listener;
|
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()
|
public static void StartThread()
|
||||||
{
|
{
|
||||||
if (!Started)
|
if (!Started)
|
||||||
{
|
{
|
||||||
(new Thread(Start)).Start();
|
startThread = new Thread(Start);
|
||||||
(new Thread(SendHeartbeat)).Start();
|
startThread.Start();
|
||||||
|
|
||||||
|
heartbeat = new Thread(SendHeartbeat);
|
||||||
|
heartbeat.Start();
|
||||||
}
|
}
|
||||||
Started = true;
|
Started = true;
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +74,7 @@ namespace TShockAPI
|
||||||
Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}",
|
Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}",
|
||||||
ListenPort,
|
ListenPort,
|
||||||
Password));
|
Password));
|
||||||
Thread listen = new Thread(Listener);
|
listen = new Thread(Listener);
|
||||||
listen.Start();
|
listen.Start();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
@ -161,8 +178,8 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
response = "Bad rconpassword.\n";
|
response = "Bad rcon password.\n";
|
||||||
Log.ConsoleInfo("Bad rconpassword from " + EP);
|
Log.ConsoleInfo("Bad rcon password from " + EP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -170,7 +187,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
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");
|
Log.Info("No password for rcon set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -328,7 +345,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if ((DateTime.UtcNow - LastHeartbeat).Seconds >= 30)
|
if ((DateTime.UtcNow - LastHeartbeat).Seconds >= 30)
|
||||||
{
|
{
|
||||||
var packet = ConstructPacket("heartbeat TERRARIA", false);
|
var packet = ConstructPacket("heartbeat TerrariaShock", false);
|
||||||
if (listener == null)
|
if (listener == null)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
GetDataHandlers.InitGetDataHandler();
|
GetDataHandlers.InitGetDataHandler();
|
||||||
Commands.InitCommands();
|
Commands.InitCommands();
|
||||||
//RconHandler.StartThread();
|
RconHandler.StartThread();
|
||||||
|
|
||||||
if (Config.BufferPackets)
|
if (Config.BufferPackets)
|
||||||
PacketBuffer = new PacketBufferer();
|
PacketBuffer = new PacketBufferer();
|
||||||
|
|
@ -226,6 +226,7 @@ namespace TShockAPI
|
||||||
Console.WriteLine("Thanks for using TShock! Process ID file is now being destroyed.");
|
Console.WriteLine("Thanks for using TShock! Process ID file is now being destroyed.");
|
||||||
File.Delete(Path.Combine(SavePath, "tshock.pid"));
|
File.Delete(Path.Combine(SavePath, "tshock.pid"));
|
||||||
}
|
}
|
||||||
|
RconHandler.ShutdownAllThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue