private static void Main(string[] args)
{
Console.WriteLine(
"BattleNET v1.3.3 - BattlEye Library and Client\n\n" +
"Copyright (C) 2015 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.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 */ };
}
else
{
while (true)
{
string cmd = Console.ReadLine();
if (cmd == "exit" || cmd == "logout")
{
break;
}
if (b.Connected)
{
b.SendCommand(cmd);
}
else
{
Environment.Exit(0);
}
}
}
b.Disconnect();
}