private void OnDisconnect(BattlEyeLoginCredentials loginDetails, EBattlEyeDisconnectionType disconnectionType) { if (DisconnectEvent != null) { DisconnectEvent(new BattlEyeDisconnectEventArgs(loginDetails, disconnectionType)); } }
public BattlEyeDisconnectEventArgs(BattlEyeLoginCredentials loginDetails, EBattlEyeDisconnectionType disconnectionType) { LoginDetails = loginDetails; DisconnectionType = disconnectionType; switch (DisconnectionType) { case EBattlEyeDisconnectionType.ConnectionLost: Message = "Disconnected! (Connection timeout)"; break; case EBattlEyeDisconnectionType.LoginFailed: Message = "Disconnected! (Failed to login)"; break; case EBattlEyeDisconnectionType.Manual: Message = "Disconnected!"; break; case EBattlEyeDisconnectionType.SocketException: Message = "Disconnected! (Socket Exception)"; break; case EBattlEyeDisconnectionType.ConnectionFailed: Message = "Connection failed!"; break; } }
private void OnDisconnect(BattlEyeLoginCredentials loginDetails, BattlEyeDisconnectionType?disconnectionType) { if (BattlEyeDisconnected != null) { BattlEyeDisconnected(new BattlEyeDisconnectEventArgs(loginDetails, disconnectionType)); } }
private static void Main(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); #region loginCredentials.Host = args[0]; loginCredentials.Port = Convert.ToInt32(args[1]); loginCredentials.Password = args[2]; #endregion IBattleNET b = new BattlEyeClient(loginCredentials); b.MessageReceivedEvent += DumpMessage; b.DisconnectEvent += Disconnected; b.ReconnectOnPacketLoss(true); b.Connect(); if (b.IsConnected() == false) { Console.WriteLine("Couldnt connect to server"); Console.WriteLine("Failed to reload bans"); return; } b.SendCommandPacket(EBattlEyeCommand.loadBans); Thread.Sleep(1000); // wait 1 second for no reason... b.Disconnect(); }
public void setLoginData(string host, int port, string password) { this.loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password }; }
private void OnConnect(BattlEyeLoginCredentials loginDetails, BattlEyeConnectionResult connectionResult) { if (connectionResult == BattlEyeConnectionResult.ConnectionFailed || connectionResult == BattlEyeConnectionResult.InvalidLogin) { Disconnect(null); } BattlEyeConnected?.Invoke(new BattlEyeConnectEventArgs(loginDetails, connectionResult)); }
private static BattlEyeLoginCredentials GetLoginCredentials(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); loginCredentials.Host = null; loginCredentials.Port = 0; loginCredentials.Password = ""; for (int i = 0; i < args.Length; i = i + 2) { switch (args[i]) { case "-host": { try { IPAddress ip = Dns.GetHostAddresses(args[i + 1])[0]; loginCredentials.Host = ip; } catch { Console.WriteLine("No valid host given!"); } break; } case "-port": { int value; if (int.TryParse(args[i + 1], out value)) { loginCredentials.Port = value; } else { Console.WriteLine("No valid port given!"); } break; } case "-password": { if (args[i + 1] != "") { loginCredentials.Password = args[i + 1]; } else { Console.WriteLine("No password given!"); } break; } } } return loginCredentials; }
private static BattlEyeLoginCredentials GetLoginCredentials() { string ip = ""; int port = 0; string password = ""; do { IPAddress value; string input; Console.Write("Enter IP address: "); input = Console.ReadLine(); if (IPAddress.TryParse(input, out value)) { ip = value.ToString(); } } while (ip == ""); do { int value; string input; Console.Write("Enter port number: "); input = Console.ReadLine(); if (int.TryParse(input, out value)) { port = value; } } while (port == 0); do { Console.Write("Enter RCon password: "******"") { password = input; } } while (password == ""); var loginCredentials = new BattlEyeLoginCredentials { Host = ip, Port = port, Password = password, }; return loginCredentials; }
private static BattlEyeLoginCredentials GetLoginCredentials(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-host": { IPAddress value; if (IPAddress.TryParse(args[i + 1], out value)) { loginCredentials.Host = value.ToString(); } else { Console.WriteLine("No valid host given!", args[i + 1]); } break; } case "-port": { int value; if (int.TryParse(args[i + 1], out value)) { loginCredentials.Port = value; } else { Console.WriteLine("No valid port given!", args[i + 1]); } break; } case "-password": { if (args[i + 1] != "") { loginCredentials.Password = args[i + 1]; } else { Console.WriteLine("No password given!"); } break; } } } return loginCredentials; }
private void OnConnect(BattlEyeLoginCredentials loginDetails, BattlEyeConnectionResult connectionResult) { LogType logtype = (connectionResult == BattlEyeConnectionResult.Success) ? LogType.Connected : LogType.Disconnected; if (lastLog != logtype) { if (loginAccepted == false) { if (connectionResult == BattlEyeConnectionResult.ConnectionFailed || connectionResult == BattlEyeConnectionResult.InvalidLogin) { Disconnect(null); } } if (BattlEyeConnected != null) { BattlEyeConnected(new BattlEyeConnectEventArgs(loginDetails, connectionResult)); } lastLog = logtype; } }
private static void Main(string[] args) { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); #region if (args.Length == 3) { loginCredentials.Host = args[0]; loginCredentials.Port = Convert.ToInt32(args[1]); loginCredentials.Password = args[2]; } else { Console.WriteLine("Wrong Number of Args"); Thread.Sleep(5000); Environment.Exit(0); } #endregion BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); if (b.Connected) { b.SendCommand(BattlEyeCommand.LoadBans); while (b.CommandQueue > 0) { /* wait until server received packet */ }; Thread.Sleep(1000); // wait 1 second for no reason... } else { Console.WriteLine("Couldnt connect to server"); Console.WriteLine("Failed to reload bans"); Environment.Exit(0); } b.Disconnect(); }
public BattlEyeClient(BattlEyeLoginCredentials loginCredentials) { this.loginCredentials = loginCredentials; }
private void mnuConnect_Click(object sender, EventArgs e) { if (isConnected == false) { BattlEyeLoginCredentials logcred = new BattlEyeLoginCredentials { Host = ip, Password = password, Port = Convert.ToInt32(port) }; b = new BattlEyeClient(logcred); keepAliveTimer = new Timer(); keepAliveTimer.Tick += new EventHandler(sendKeepAlivePacket); keepAliveTimer.Interval = 30000; // in miliseconds rtbDisplay.AppendText("\n Connecting...\n"); // make the connection b.MessageReceivedEvent += DumpMessage; b.DisconnectEvent += Disconnected; b.ReconnectOnPacketLoss(true); b.Connect(); if (b.IsConnected() == true) { isConnected = true; mnuConnect.Enabled = false; b.SendCommandPacket(""); keepAliveTimer.Start(); if (showStartupMsg == true) { b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Whitelister started"); } } } }
private void OnDisconnect(BattlEyeLoginCredentials loginDetails, BattlEyeDisconnectionType?disconnectionType) { BattlEyeDisconnected?.Invoke(new BattlEyeDisconnectEventArgs(loginDetails, disconnectionType)); }
public BattlEyeDisconnectEventArgs(BattlEyeLoginCredentials loginDetails, BattlEyeDisconnectionType?disconnectionType) { LoginDetails = loginDetails; DisconnectionType = disconnectionType; Message = Helpers.StringValueOf(disconnectionType); }
public BattlEyeConnectEventArgs(BattlEyeLoginCredentials loginDetails, BattlEyeConnectionResult connectionResult) { LoginDetails = loginDetails; ConnectionResult = connectionResult; Message = Helpers.StringValueOf(connectionResult); }
public void Connect(IPAddress host, int port, string password) { _credentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password }; _client = new BattlEyeClient(_credentials); _client.BattlEyeMessageReceived += HandleMessage; _client.BattlEyeConnected += HandleConnect; _client.BattlEyeDisconnected += HandleDisconnect; _client.ReconnectOnPacketLoss = false; _initialized = true; _client.Connect(); }
private void OnDisconnect(BattlEyeLoginCredentials loginDetails, BattlEyeDisconnectionType? disconnectionType) { if (BattlEyeDisconnected != null) BattlEyeDisconnected(new BattlEyeDisconnectEventArgs(loginDetails, disconnectionType)); }
private BattlEyeClient BEClient() { AppConsole.Log("Loading BEClient..."); var login = new BattlEyeLoginCredentials { Host = _settings.Address, Port = _settings.Port, Password = _settings.RconPass }; var beclient = new BattlEyeClient(login) {ReconnectOnPacketLoss = true}; beclient.BattlEyeConnected += BattlEyeConnected; beclient.BattlEyeDisconnected += BattlEyeDisconnected; return beclient; }
private void setLoginData(string host, int port, string password) { this.write("Starting Login Data...", ConsoleColor.DarkMagenta); this.loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password }; }
private static BattlEyeLoginCredentials GetLoginCredentials() { IPAddress host = null; int port = 0; string password = ""; do { string input; Console.Write("Enter IP address or hostname: "); input = Console.ReadLine(); try { IPAddress ip = Dns.GetHostAddresses(input)[0]; host = ip; } catch { /* try again */ } } while (host == null); do { int value; string input; Console.Write("Enter port number: "); input = Console.ReadLine(); if (int.TryParse(input, out value)) { port = value; } } while (port == 0); do { Console.Write("Enter RCon password: "******"") { password = input; } } while (password == ""); var loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password, }; return loginCredentials; }
private BattlEyeLoginCredentials PrepareLoginCredentials() { IPAddress host = null; int port = profileSelected.Port; string password = profileSelected.Password; var loginCredentials = new BattlEyeLoginCredentials { }; try { IPAddress ip = Dns.GetHostAddresses(profileSelected.Hostname)[0]; host = ip; loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password, }; } catch (Exception e) { Logger.ExceptionLogger.Error("Attempt to prepareLoginCredentials error : " + profileSelected.ToString() + "\n" + e.ToString()); } return loginCredentials; }
private void OnDisconnect(BattlEyeLoginCredentials loginDetails, EBattlEyeDisconnectionType disconnectionType) { if (DisconnectEvent != null) DisconnectEvent(new BattlEyeDisconnectEventArgs(loginDetails, disconnectionType)); }
private void InitClients() { _log.Info(string.Format("{0}:{1} Update client - InitClients", _host, _port)); lock (_lock) { if (_battlEyeClient != null) ReleaseClient(); var credentials = new BattlEyeLoginCredentials(IPAddress.Parse(_host), _port, _password); _battlEyeClient = new BattlEyeClient(credentials); _battlEyeClient.ReconnectOnPacketLoss = true; _battlEyeClient.BattlEyeConnected += battlEyeClient_BattlEyeConnected; _battlEyeClient.BattlEyeDisconnected += _battlEyeClient_BattlEyeDisconnected; _battlEyeClient.BattlEyeMessageReceived += battlEyeClient_BattlEyeMessageReceived; } }
private void OnConnect(BattlEyeLoginCredentials loginDetails, BattlEyeConnectionResult connectionResult) { if (connectionResult == BattlEyeConnectionResult.ConnectionFailed || connectionResult == BattlEyeConnectionResult.InvalidLogin) Disconnect(null); if (BattlEyeConnected != null) BattlEyeConnected(new BattlEyeConnectEventArgs(loginDetails, connectionResult)); }
public BattlEyeDisconnectEventArgs(BattlEyeLoginCredentials loginDetails, BattlEyeDisconnectionType? disconnectionType) { LoginDetails = loginDetails; DisconnectionType = disconnectionType; Message = Helpers.StringValueOf(disconnectionType); }
static void Main(string[] args) { string cfgFile; Boolean goodFile = false; BattlEyeLoginCredentials loginCredentials; Config cfg = new Config(); Dictionary<string, string> ArgPairs = new Dictionary<string, string>(); if (args.Length == 1) { string arg1 = args[0]; // validate we have arguments if (arg1.Contains("--configfile=") && arg1.Contains(".xml")) { string[] ArgSplit = arg1.Split('='); if (ArgSplit.Length == 2) { // get cfg file cfgFile = ArgSplit[1]; // get data from cfg file goodFile = cfg.GetSettingsFromXML(cfgFile); } } } // cli specified args // usage: ServerRestartDeluxe.exe server=127.0.0.1 port=2302 password=pw else if (args.Length > 1) { // split up args foreach (string inputArg in args) { if (inputArg.Contains("=")) { string[] pair = inputArg.Split('='); ArgPairs.Add(pair[0], pair[1]); } } // parse argpairs foreach (KeyValuePair<string, string> argPair in ArgPairs) { switch (argPair.Key) { case "server": cfg.IP = argPair.Value.ToString(); break; case "port": cfg.Port = argPair.Value.ToString(); break; case "password": cfg.Password = argPair.Value.ToString(); break; } } // assume good - Fix Later - JG goodFile = true; } if (goodFile == true) { // establish connection loginCredentials = new BattlEyeLoginCredentials(); loginCredentials.Host = cfg.IP; loginCredentials.Password = cfg.Password; loginCredentials.Port = Convert.ToInt32(cfg.Port); IBattleNET b = new BattlEyeClient(loginCredentials); b.MessageReceivedEvent += DumpMessage; b.DisconnectEvent += Disconnected; b.ReconnectOnPacketLoss(true); b.Connect(); // validate connection if (b.IsConnected() == false) { Console.WriteLine("No connection starting server"); // Process.Start(processPath); // exit return; } else { Console.Title = "DayZ Ultra Server Restart 15 min warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 15 min."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 15 min."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 15 min."); Thread.Sleep(600000); Console.Title = "DayZ Ultra Server Restart 5 minute warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 5 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 5 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 5 minutes."); Thread.Sleep(60000); Console.Title = "DayZ Ultra Server Restart 4 minute warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 4 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 4 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 4 minutes."); Thread.Sleep(60000); // wait 1 min Console.Title = "DayZ Ultra Server Restart 3 minute warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 3 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 3 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 3 minutes."); Thread.Sleep(60000); // wait 1 min Console.Title = "DayZ Ultra Server Restart 2 minute warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 2 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 2 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 2 minutes."); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 2 minutes."); Thread.Sleep(60000); // wait 1 min Console.Title = "DayZ Ultra Server Restart 1 minute warning"; b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset in 1 minute. Log off now"); // lock server b.SendCommandPacket(EBattlEyeCommand.Lock); Thread.Sleep(60000); // wait 1 min b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset NOW!"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset NOW!"); b.SendCommandPacket(EBattlEyeCommand.Say, "-1 Server going down for reset NOW!"); Console.WriteLine("Shutdown cmd"); //b.SendCommandPacket(EBattlEyeCommand.Shutdown); System.Environment.Exit(0); } // warnings } else { // exit Console.WriteLine("Error reading config file. exiting now..."); return; } }