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 BattlEyeServerProxy(BattlEyeClient client) { _battlEyeClient = client; _battlEyeClient.BattlEyeConnected += OnBattlEyeConnected; _battlEyeClient.BattlEyeMessageReceived += OnBattlEyeMessageReceived; _battlEyeClient.BattlEyeDisconnected += OnBattlEyeDisconnected; }
public BattlEyeServerProxy(BattlEyeClient client, string serverName) { _battlEyeClient = client; _serverName = serverName; _battlEyeClient.BattlEyeConnected += OnBattlEyeConnected; _battlEyeClient.BattlEyeMessageReceived += OnBattlEyeMessageReceived; _battlEyeClient.BattlEyeDisconnected += OnBattlEyeDisconnected; }
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 Api(BattlEyeClient client, ISettings settings) { _db = new DB(); _beclient = client; _settings = settings; _beclient.BattlEyeConnected += BattlEyeConnected; _beclient.BattlEyeDisconnected += BattlEyeDisconnected; _beclient.BattlEyeMessageReceived += BattlEyeMessageReceived; _getPlayersTimer.Interval = 1000; _getPlayersTimer.Elapsed += getPlayersTimer_Elapsed; _getPlayersTimer.Enabled = true; }
private static void beloop() { client = new BattlEyeClient(creds); client.BattlEyeMessageReceived += BattlEyeMessageReceived; client.BattlEyeConnected += BattlEyeConnected; client.BattlEyeDisconnected += BattlEyeDisconnected; client.ReconnectOnPacketLoss = true; do { if (client.Connected == false) { client.Connect(); } Thread.Sleep(1000 * 10); }while(true); }
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; }
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 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); }
protected override void DisposeManagedResources() { _log.Info($"{_serverName}: Dispose"); var local = _battlEyeClient; _battlEyeClient = null; if (local != null) { local.BattlEyeConnected -= OnBattlEyeConnected; local.BattlEyeMessageReceived -= OnBattlEyeMessageReceived; local.BattlEyeDisconnected -= OnBattlEyeDisconnected; if (local.Connected) { local.Disconnect(); } } base.DisposeManagedResources(); }
/* * 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(); } }
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; }
protected override void DisposeManagedResources() { if (_battlEyeClient != null) { lock (_lock) { if (_battlEyeClient != null) { _battlEyeClient.BattlEyeConnected -= OnBattlEyeConnected; _battlEyeClient.BattlEyeMessageReceived -= OnBattlEyeMessageReceived; _battlEyeClient.BattlEyeDisconnected -= OnBattlEyeDisconnected; if (_battlEyeClient.Connected) { _battlEyeClient.Disconnect(); } _battlEyeClient = null; } } } base.DisposeManagedResources(); }
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; } }
private static void Main(string[] args) { Console.WriteLine( "BattleNET v1.3 - BattlEye Library and Client\n\n" + "Copyright (C) 2013 by it's authors.\n" + "Some rights reserved. See license.txt, authors.txt.\n" ); BattlEyeLoginCredentials loginCredentials; string command = ""; Console.OutputEncoding = Encoding.UTF8; if (args.Length > 0) { loginCredentials = GetLoginCredentials(args); for (int i = 0; i < args.Length; i++) { if (args[i] == "-command") { try { command = args[i + 1]; } catch { Console.WriteLine("No command given!"); loginCredentials.Host = null; } } } if (loginCredentials.Host == null || loginCredentials.Port == 0 || loginCredentials.Password == "") { Console.WriteLine("BattleNET client usage:"); Console.WriteLine("BattleNET client.exe -host 127.0.0.1 -port 2302 -password admin [-command shutdown]"); Console.Read(); Environment.Exit(0); } } else { loginCredentials = GetLoginCredentials(); } Console.Title = string.Format("BattleNET client v1.3 - {0}:{1}", loginCredentials.Host, loginCredentials.Port); BattlEyeClient b = new BattlEyeClient(loginCredentials); b.BattlEyeMessageReceived += BattlEyeMessageReceived; b.BattlEyeConnected += BattlEyeConnected; b.BattlEyeDisconnected += BattlEyeDisconnected; b.ReconnectOnPacketLoss = true; b.Connect(); if (command != "") { b.SendCommand(command); while (b.CommandQueue > 0) /* wait until server received packet */ } { ; }
public bool Init(BattlEyeClient client) { beclient = client; if (!File.Exists("plugins/config/whitelist.cfg")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: whitelist.cfg nicht gefunden)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } config = readConfig(); if (config.Length < 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: Nicht alle Parameter angegeben)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } if (!(config[0] == "true" || config[0] == "false")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: activated <true/false>)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } if (config[1] == "") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: kickreason <string>)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } if (config[2] == "") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: whitelist <guid,guid,guid,...>)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } if (config[3] == "") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tWhitelist (Konfigfehler: admins <guid,guid,guid,...>)"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } client.BattlEyeMessageReceived += BattlEyeMessageReceived; if (config[0] != "true") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin deaktiviert:\tWhitelist"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("=> Plugin geladen:\tWhitelist"); Console.ForegroundColor = ConsoleColor.Gray; return(true); }
public void Run(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Console.Title = "MBCon - Connecting..."; #if DEBUG AppConsole.Log(String.Format("MBCon - WARNING THIS IS A DEBUG APP!!!"), ConsoleColor.Red); AppConsole.Log(String.Format("MBCon - WARNING THIS IS A DEBUG APP!!!"), ConsoleColor.Red); AppConsole.Log(String.Format("MBCon - WARNING THIS IS A DEBUG APP!!!"), ConsoleColor.Red); AppConsole.Log(String.Format("MBCon - WARNING THIS IS A DEBUG APP!!!"), ConsoleColor.Red); AppConsole.Log(String.Format("MBCon - WARNING THIS IS A DEBUG APP!!!"), ConsoleColor.Red); #else AppConsole.Log(String.Format("=========================="), ConsoleColor.DarkCyan); AppConsole.Log(String.Format("MBCon - by maca134"), ConsoleColor.Cyan); AppConsole.Log(String.Format("*****@*****.**"), ConsoleColor.Gray); AppConsole.Log(String.Format("=========================="), ConsoleColor.DarkCyan); AppConsole.Log(""); Thread.Sleep(4000); #endif _args.Setup <string>("config") .Callback(val => _configPath = val) .SetDefault(Path.Combine(BasePath, "config.ini")); _args.Setup <int>("delay") .Callback(val => _startupDelay = val) .SetDefault(0); _args.Parse(args); if (!File.Exists(_configPath)) { throw new CoreException(String.Format("Config file \"{0}\" was not found.", _configPath)); } AppConsole.Log("Config file found, continuing to load..."); var ini = new IniParser(_configPath); try { _settings = new Settings(ini); } catch (SettingsException ex) { throw new CoreException(String.Format("Error Loading Settings: {0}", ex.Message)); } if (_startupDelay > 0) { AppConsole.Log(string.Format("Waiting for {0} seconds", _startupDelay)); Thread.Sleep(_startupDelay * 1000); } _beclient = BEClient(); _pluginManager = new PluginManager(PluginPath); _api = new Api(_beclient, _settings); _pluginManager.Init(_api); AppConsole.Log("Connecting to server..."); Connect(); }
static beConn() { b = new BattlEyeClient(settings.loginCredentials); }
public bool Init(BattlEyeClient client) { beclient = client; //Config Check byte cfgCheckNr = configCheck("plugins/config/scriptban.cfg"); if (cfgCheckNr > 0) { string errorMsg = ""; switch (cfgCheckNr) { case 1: errorMsg = "Configdatei konnte nicht gefunden werden"; break; case 2: errorMsg = "Config fehlerhaft - Nicht alle Parameter vorhanden"; break; case 3: errorMsg = "Syntaxfehler in der Configdatei"; break; default: errorMsg = "Unbekannter Fehler"; break; } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(string.Format("=> Plugin Fehler:\tScriptBan\t{0}", errorMsg)); Console.ForegroundColor = ConsoleColor.Gray; return(false); } //Filepath Check if (CONFIG[0] == "true" && !Directory.Exists(CONFIG[1])) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("=> Plugin Fehler:\tScriptBan\tDateipfad für File-Logs existiert nicht"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } //Database Connection Check if (CONFIG[2] == "true") { //Database Connection String CONNECTIONSTRING = "server=" + CONFIG[3] + ";database=" + CONFIG[4] + ";uid=" + CONFIG[5] + ";password="******"=> Plugin Fehler:\tScriptBan\tVerbindung zur Datenbank konnte nicht aufgebaut werden"); Console.ForegroundColor = ConsoleColor.Gray; return(false); } } client.BattlEyeMessageReceived += BattlEyeMessageReceived; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("=> Plugin geladen:\tScriptBan"); Console.ForegroundColor = ConsoleColor.Gray; return(true); }