public IBattlEyeServer Create(BattlEyeLoginCredentials credentials) { return(new ThreadSafeBattleEyeServer(new BattlEyeServerProxy(new BattlEyeClient(credentials) { ReconnectOnPacketLoss = true }, $"{credentials.Host}:{credentials.Port}"))); }
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... }
private static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; Console.Title = "BattleNET Client"; BattlEyeLoginCredentials loginCredentials = GetLoginCredentials(); Console.Title += string.Format(" - {0}:{1}", loginCredentials.Host, loginCredentials.Port); IBattleNET b = new BattlEyeClient(loginCredentials); b.MessageReceivedEvent += DumpMessage; b.DisconnectEvent += Disconnected; b.ReconnectOnPacketLoss(true); b.Connect(); while (true) { string cmd = Console.ReadLine(); if (cmd == "exit" || cmd == "logout") { Environment.Exit(0); } if (b.IsConnected()) { b.SendCommandPacket(cmd); } else { Console.WriteLine("Not connected!"); } } }
public void setLoginData(string host, int port, string password) { this.loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = port, Password = password }; }
public BEConnectedWatcher(IBattlEyeServerFactory battlEyeServerFactory, BattlEyeLoginCredentials credentials) { _battlEyeServerFactory = battlEyeServerFactory; _credentials = credentials; _timer = new Timer(_timer_Elapsed, null, 5000, 10000); Init(); }
public BE_Server(BattlEyeLoginCredentials pCredentials, String pIdentifier) { this.ServerIdentifier = pIdentifier; this.Players = new List <BE_Player>(); this.Online = false; this.Executor = new BE_Executor(); this.Executor.ClientMessageReceived += new BE_Executor.MessageReceivedEventHandler(RouteMessage); this.Executor.Listen(pCredentials); }
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 }; }
public BEConnectedWatcher(IBattlEyeServerFactory battlEyeServerFactory, BattlEyeLoginCredentials credentials) { _battlEyeServerFactory = battlEyeServerFactory; _credentials = credentials; _timer = new Timer(_timer_Elapsed, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10)); _keepAliveTimer = new Timer(_timer_KeepAlive, null, TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2)); _battlEyeServer = Init(_credentials); }
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 IBattlEyeServer Init(BattlEyeLoginCredentials battlEyeLoginCredentials) { Log.Info($"Init {battlEyeLoginCredentials.Host}:{battlEyeLoginCredentials.Port}"); var battlEyeServer = _battlEyeServerFactory.Create(battlEyeLoginCredentials); battlEyeServer.BattlEyeConnected += OnBattlEyeConnected; battlEyeServer.BattlEyeMessageReceived += OnBattlEyeMessageReceived; battlEyeServer.BattlEyeDisconnected += OnBattlEyeDisconnected; return(battlEyeServer); }
static void Main(string[] args) { try { IPAddress host = IPAddress.Parse("127.0.0.1"); // Адрес Arma 2 OA сервера для подключения int sport = 2302; // Порт Arma 2 OA string password = "******"; // Пароль BEServer BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials { Host = host, Port = sport, Password = password, }; b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); listener = new TcpListener(IPAddress.Parse("0.0.0.0"), port); // Адрес сервера для прослушивания listener.Start(); if (ClientObject.debug) { Console.WriteLine("Ожидание подключений..."); } b.SendCommand("Players"); Thread reloadthread = new Thread(new ThreadStart(bereload)); reloadthread.Start(); while (true) { TcpClient client = listener.AcceptTcpClient(); ClientObject clientObject = new ClientObject(client); // создаем новый поток для обслуживания нового клиента Thread clientThread = new Thread(new ThreadStart(clientObject.Process)); clientThread.Start(); } } catch (Exception ex) { if (ClientObject.debug) { Console.WriteLine(ex.Message); } } finally { if (listener != null) { listener.Stop(); } } }
public IBattlEyeServer Create(BattlEyeLoginCredentials credentials) { if (ConfigurationManager.AppSettings[DebugServerKey] == bool.TrueString) { return(new BattlEyeServerLogProxy(new MockBattleEyeServer())); } return(new ThreadSafeBattleEyeServer(new BattlEyeServerProxy(new BattlEyeClient(credentials) { ReconnectOnPacketLoss = true }, $"{credentials.Host}:{credentials.Port}"))); }
private void Release(IBattlEyeServer battlEyeServer, BattlEyeLoginCredentials battlEyeLoginCredentials) { Log.Info($"Release {battlEyeLoginCredentials.Host}:{battlEyeLoginCredentials.Port}"); if (battlEyeServer != null) { battlEyeServer.BattlEyeConnected -= OnBattlEyeConnected; battlEyeServer.BattlEyeMessageReceived -= OnBattlEyeMessageReceived; battlEyeServer.BattlEyeDisconnected -= OnBattlEyeDisconnected; if (battlEyeServer.Connected) { battlEyeServer.Disconnect(); } battlEyeServer.Dispose(); } }
private void InitClients() { _log.Info($"{_host}:{_port} Update client - InitClients"); lock (_lock) { if (_battlEyeServer != null) { ReleaseClient(); } var credentials = new BattlEyeLoginCredentials(IPAddress.Parse(_host), _port, _password); _battlEyeServer = _battlEyeServerFactory.Create(credentials); _battlEyeServer.BattlEyeConnected += BattlEyeServerBattlEyeConnected; _battlEyeServer.BattlEyeDisconnected += BattlEyeServerBattlEyeDisconnected; _battlEyeServer.BattlEyeMessageReceived += BattlEyeServerBattlEyeMessageReceived; } }
/* Public methods */ public void Listen(BattlEyeLoginCredentials pCredentials) { BEClient = new BattleNET.BattlEyeClient(pCredentials) { ReconnectOnPacketLoss = true }; BEClient.BattlEyeMessageReceived += new BattlEyeMessageEventHandler(MessageReceived); BEClient.BattlEyeDisconnected += new BattlEyeDisconnectEventHandler(Disconnected); BEClient.BattlEyeConnected += new BattlEyeConnectEventHandler(Connected); while (BEClient.Connect() != BattlEyeConnectionResult.Success) { Thread.Sleep(Timeout); Console.WriteLine("Retrying RCON connection to {0}:{1}", pCredentials.Host, pCredentials.Port); } }
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(); }
public void SetSettingsFile(Settings settings) { this._settings = settings; IPAddress.TryParse(_settings.ip, out IPAddress address); var credentials = new BattlEyeLoginCredentials { Host = address, Port = _settings.port, Password = _settings.password }; _client = new BattlEyeClient(credentials) { ReconnectOnPacketLoss = true }; _client.BattlEyeDisconnected += Client_BattlEyeDisconnected; _client.BattlEyeConnected += Client_BattlEyeConnected; }
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); }
/* * Primary connect and disconnect handlers */ #region CXN_MAIN private void btnConnect_Click(object sender, EventArgs e) { if (isConnected) { handleDisconnect(); b.Disconnect(); } else { loginCredentials = GetLoginCredentials(); b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); //handleConnect(); } }
private BattlEyeLoginCredentials GetLoginCredentials() { BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); try { loginCredentials.Host = Dns.GetHostAddresses(txHost.Text)[0]; } catch { MessageBox.Show("Error resolving hostname. Are you using the right address?"); } try { loginCredentials.Port = Convert.ToInt32(txPort.Text); } catch { loginCredentials.Port = 3202; }; loginCredentials.Password = txPasswd.Text; txAll.AppendText(txHost.Text + " (" + Dns.GetHostAddresses(txHost.Text)[0] + ")\n"); return(loginCredentials); }
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(); string[] strArray = new string[Settings.Default.hilight.Count]; Settings.Default.hilight.CopyTo(strArray, 0); _hilight = strArray; }
public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // mode = ConfigurationManager.AppSettings["mode"]; InitializeComponent(); creds = new BattlEyeLoginCredentials(); creds.Host = IPAddress.Parse(ConfigurationManager.AppSettings["behost"]); creds.Port = Convert.ToInt32(ConfigurationManager.AppSettings["beport"]); creds.Password = ConfigurationManager.AppSettings["bepass"]; cs = new MySqlConnectionStringBuilder(); cs.Server = ConfigurationManager.AppSettings["sqlhost"]; cs.UserID = ConfigurationManager.AppSettings["sqluser"]; cs.Password = ConfigurationManager.AppSettings["sqlpass"]; cs.Database = ConfigurationManager.AppSettings["sqldatabase"]; beloopThread = new Thread(beloop); beloopThread.IsBackground = true; }
public IBattlEyeServer Create(BattlEyeLoginCredentials credentials) { return(new BEConnectedWatcher(new BattlEyeServerFactory(_log), _log, credentials)); }
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; } }
public IBattlEyeServer Create(BattlEyeLoginCredentials credentials) { return(_server.Value); }