static void Main(string[] args) { var OutputMode = AppSettings["outputMode"]; IMessage Messenger = null; switch (OutputMode) { case "Console": Messenger = new ConsoleMsg(); break; case "Web": Messenger = new WebMsg(); break; default: Console.WriteLine("Unable to determine output method"); Console.WriteLine("Aborting"); Console.ReadKey(); return; } Console.WriteLine(Messenger.OutputMessage()); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private ConsoleMsg getConsoleMsg() { ConsoleMsg result = null; if (consoleMsgPool.Count == 0) { result = new ConsoleMsg(); consoleMsgPool.Add(result); return(result); } List <ConsoleMsg> .Enumerator tor = consoleMsgPool.GetEnumerator(); while (tor.MoveNext()) { if (tor.Current.DispatchTime == 0) { result = tor.Current; break; } } if (result == null) { result = new ConsoleMsg(); consoleMsgPool.Add(result); } consoleMsgPool.Sort(CompareByDispatchTime); return(result); }
public void TestConsole() { IMessage Messenger = new ConsoleMsg(); if (string.IsNullOrEmpty(Messenger.OutputMessage())) { Assert.Fail(); } }
public void PrintAppPID() { if (PID < 0) { ConsoleMsg.Write("Sea of Thieves is not running !", ConsoleMsg.Type.Error, true); } else { ConsoleMsg.Write($"Found Sea of Thieves [{PID}]", ConsoleMsg.Type.Info); } }
private void PrintPacketInfo(Packet packet) { IpV4Datagram ip = packet.Ethernet.IpV4; UdpDatagram udp = ip.Udp; if (!ip.Destination.ToString().Contains("192")) { string server = ip.Destination + ":" + udp.DestinationPort; ConsoleMsg.Write($"Connected to game server : {server}", ConsoleMsg.Type.Info, true); if (!String.IsNullOrEmpty(Constants.DiscordWebHook)) { Webhook.SendMessage(PlayerName, server); } pm.Break(); } }
public static bool CheckDangerousMaterialsInput(string i_InputToCheck) { bool isValid = i_InputToCheck.Length == 1; if (isValid) { isValid = char.ToUpper(i_InputToCheck[0]) == 'Y' || char.ToUpper(i_InputToCheck[0]) == 'N'; } if (!isValid) { ConsoleMsg.ErrorMsgInput(); } return(isValid); }
public void NetstatAppPID() { string protocol = "UDP"; if (PID < 0) { ConsoleMsg.Write("Sea of Thieves is not running !", ConsoleMsg.Type.Error, true); return; } try { using (Process p = new Process()) { ProcessStartInfo ps = new ProcessStartInfo(); ps.Arguments = "-aonp " + protocol; ps.FileName = "netstat.exe"; ps.UseShellExecute = false; ps.WindowStyle = ProcessWindowStyle.Hidden; ps.RedirectStandardInput = true; ps.RedirectStandardOutput = true; ps.RedirectStandardError = true; p.StartInfo = ps; p.Start(); StreamReader stdOutput = p.StandardOutput; StreamReader stdError = p.StandardError; string rawData = stdOutput.ReadToEnd() + stdError.ReadToEnd(); string exitStatus = p.ExitCode.ToString(); string line; StringReader reader = new StringReader(rawData); while ((line = reader.ReadLine()) != null) { if (line.Contains(PID.ToString())) { AddPort(line, protocol); } } } } catch (Exception ex) { ConsoleMsg.Write(ex.TargetSite + " " + ex.Message, ConsoleMsg.Type.Error); } }
public static bool CheckEnergyPercentage(string i_InputToCheck) { float energyPercentage; bool isValid = float.TryParse(i_InputToCheck, out energyPercentage); if (isValid) { isValid = energyPercentage > 0 && energyPercentage <= 100; } if (!isValid) { ConsoleMsg.EnergyPercentageError(); } return(isValid); }
public static bool CheckLicenseType(string i_InputToCheck) { int result; bool isValid = int.TryParse(i_InputToCheck, out result); if (isValid) { isValid = result > 0 && result < 5; } if (!isValid) { ConsoleMsg.LicenseTypeError(); } return(isValid); }
public static bool CheckGarageMenuInput(string i_InputToCheck) { int result; bool isValid = int.TryParse(i_InputToCheck, out result); if (isValid) { isValid = result > 0 && result <= k_NumberOfMenuOptions; } if (!isValid) { ConsoleMsg.ErrorMenuMsg(); } return(isValid); }
public static bool TypeRangeCheck(string i_InputToCheck) { int result; bool isValid = int.TryParse(i_InputToCheck, out result); if (isValid) { isValid = result > 0 && result <= k_NumberOfFilterOptions; } if (!isValid) { ConsoleMsg.ErrorMenuMsg(); } return(isValid); }
public static bool CheckEngineCapacity(string i_InputToCheck) { int result; bool isValid = int.TryParse(i_InputToCheck, out result); if (isValid) { isValid = result > 0; } if (!isValid) { ConsoleMsg.EngineCapacityError(); } return(isValid); }
public void SendMessage(float delay, int msgID, params object[] ExtraInfo) { if (msgRecived == null) { return; } if (delay <= 0) { msgRecived(msgID, ExtraInfo); } else { float CurrentTime = Time.time; CurrentTime += delay; ConsoleMsg msg = getConsoleMsg(); //ConsoleMsg msg = new ConsoleMsg(); msg.Set(CurrentTime, msgID, ExtraInfo); } }
public void FindAppPID() { try { using (Process p = Process.GetProcessesByName(Executable).Last()) { PID = p.Id; ConsoleMsg.Write($"Found Sea of Thieves [{PID}]", ConsoleMsg.Type.Info); } if (!String.IsNullOrEmpty(Constants.DiscordWebHook)) { ConsoleMsg.Write("Type your nickname :", ConsoleMsg.Type.Info); PlayerName = Console.ReadLine(); } } catch (Exception) { //Console.WriteLine(String.Format("No PID: [{0}] '{1}'", Executable, Title)); } }
public static bool CheckEnergyTypeRange(string i_InputToCheck) { bool isValid = i_InputToCheck.Length == 1; if (isValid) { isValid = char.IsDigit(i_InputToCheck[0]); if (i_InputToCheck[0] < '1' || i_InputToCheck[0] > '2') { isValid = false; } } if (!isValid) { ConsoleMsg.ErrorMenuMsg(); } return(isValid); }
public static bool CheckNumbersOfDoors(string i_InputToCheck) { bool isValid = i_InputToCheck.Length == 1; if (isValid) { isValid = char.IsDigit(i_InputToCheck[0]); if (i_InputToCheck[0] < '2' || i_InputToCheck[0] > '5') { isValid = false; } } if (!isValid) { ConsoleMsg.ErrorAmount(); } return(isValid); }
public void InterceptPortPackets(List <LivePacketDevice> devices) { if (devices.Count == 0) { ConsoleMsg.Write("Eth error", ConsoleMsg.Type.Error); return; } try { if (Ports.Count != 0) { foreach (LivePacketDevice dev in devices) { using (pm = dev.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 500)) { string filter = Ports[0].Protocol.ToLower() + " port " + Ports[0].Number; using (BerkeleyPacketFilter f = pm.CreateFilter(filter)) { pm.SetFilter(f); } pm.ReceivePackets(0, PrintPacketInfo); } } } else { if (Process.GetProcessesByName(Constants.SeaOfThievesExe).Length > 0) { ConsoleMsg.Write("You are not connected to any game server !", ConsoleMsg.Type.Error, true); } } } catch (Exception ex) { ConsoleMsg.Write(ex.TargetSite + " " + ex.Message, ConsoleMsg.Type.Error); } }
public static bool CheckOwnersName(string i_InputToCheck) { bool isValid = i_InputToCheck.Length > 0; if (isValid) { for (int i = 0; i < i_InputToCheck.Length; i++) { if (char.IsDigit(i_InputToCheck[i])) { isValid = false; break; } } } if (!isValid) { ConsoleMsg.ErrorNameMsg(); } return(isValid); }
public static bool CheckOwnersPhoneNumber(string i_InputToCheck) { bool isValid = i_InputToCheck.Length == k_NumberOfDigitInPhoneNumber; if (isValid) { for (int i = 0; i < i_InputToCheck.Length; i++) { if (!char.IsDigit(i_InputToCheck[i])) { isValid = false; break; } } } if (!isValid) { ConsoleMsg.ErrorPhoneNumberMsg(); } return(isValid); }
public static bool CheckCapacity(string i_InputToCheck) { bool isValid = i_InputToCheck.Length > 0; if (isValid) { for (int i = 0; i < i_InputToCheck.Length; i++) { if (!char.IsDigit(i_InputToCheck[i])) { isValid = false; break; } } } if (!isValid) { ConsoleMsg.ErrorAmount(); } return(isValid); }
public static bool CheckLicenseNumber(string i_InputToCheck) { bool isValid = i_InputToCheck.Length <= k_MaxNumberOfDigitInLicensePlate && i_InputToCheck.Length >= k_MinNumberOfDigitInLicensePlate; if (isValid) { for (int i = 0; i < i_InputToCheck.Length; i++) { if (!char.IsDigit(i_InputToCheck[i])) { isValid = false; break; } } } if (!isValid) { ConsoleMsg.ErrorLicenseNumber(); } return(isValid); }