public void ConnectTest() { RconBase client = new RconBase(); Assert.IsTrue(client.Connect(Host, Port)); Assert.IsTrue(client.Connected); client.Disconnect(); }
public void AuthenticateTest() { RconBase client = new RconBase(); client.Connect(Host, Port); Assert.IsTrue(client.Authenticate(Password)); Assert.IsTrue(client.Authenticated); client.Disconnect(); }
public static bool WorldSave(ArkServerInfo Server) { RconBase client = new RconBase(); client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort)); if (client.Connected) { client.Authenticate(Server.ServerPassword); RconPacket request = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.SaveWorld().ToString()); RconPacket response = client.SendReceive(request); string stringResponse = response?.Body.Trim(); if (stringResponse.Contains("World Saved")) { Console.WriteLine(DateTime.Now + ": Server " + Server.Name + "- World Saved!"); Methods.Log(Server, DateTime.Now + ": Server " + Server.Name + "- World Saved!"); client.Disconnect(); return(true); } } client.Disconnect(); return(false); }
public void SendReceiveTest() { RconBase client = new RconBase(); client.Connect(Host, Port); client.Authenticate(Password); RconPacket request = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.ListPlayers().ToString()); RconPacket response = client.SendReceive(request); Assert.IsInstanceOfType(response, typeof(RconPacket)); Assert.AreEqual(request.Id, response.Id); client.Disconnect(); }
public static void Connect(ArkServerInfo Server) { RconBase client = new RconBase(); client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort)); if (client.Connected) { client.Authenticate(Server.ServerPassword); //Console.WriteLine(DateTime.Now + ": Client has been successfully connected!"); Methods.Log(Server, DateTime.Now + ": Client has been successfully connected!"); } if (!client.Connected) { //Console.WriteLine(DateTime.Now + ": Client can't connect successfully!"); Methods.Log(Server, DateTime.Now + ": Client can't connect successfully!"); } client.Disconnect(); }
public static void ShutdownServer(ArkServerInfo Server) { try { RconBase client = new RconBase(); client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort)); if (client.Connected) { client.Authenticate(Server.ServerPassword); RconPacket request = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.DoExit().ToString()); RconPacket response = client.SendReceive(request); Console.WriteLine(response?.Body.Trim()); Methods.Log(Server, response?.Body.Trim()); } client.Disconnect(); } catch (Exception ex) { //Console.WriteLine(DateTime.Now + ": Exception occured when trying to send a Ark Server Shutdown Command. Exception: " + ex.Message); Methods.Log(Server, DateTime.Now + ": Exception occured when trying to send a Ark Server Shutdown Command. Exception: " + ex.Message); } }
public static void GlobalNotification(ArkServerInfo Server, string message) { try { RconBase client = new RconBase(); client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort)); if (client.Connected) { client.Authenticate(Server.ServerPassword); RconPacket request = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.Broadcast(message).ToString()); RconPacket response = client.SendReceive(request); //Console.WriteLine(DateTime.Now + ": Broadcast sent to " + Server.Name + " Server Message: " + message); Methods.Log(Server, DateTime.Now + ": Broadcast sent to " + Server.Name + " Server Message: " + message); } client.Disconnect(); } catch (Exception ex) { //Console.WriteLine(DateTime.Now + ": Exception occured when trying to send an Ark Server Global Notification. Exception: " + ex.Message); Methods.Log(Server, DateTime.Now + ": Exception occured when trying to send an Ark Server Global Notification. Exception: " + ex.Message); } }