2023-03-03 23:00:54 +03:00
|
|
|
|
using BattleBitAPI.Client;
|
|
|
|
|
using BattleBitAPI.Server;
|
2023-03-03 15:15:17 +03:00
|
|
|
|
using System.Net;
|
|
|
|
|
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2023-03-03 23:00:54 +03:00
|
|
|
|
if (Console.ReadLine().Contains("h"))
|
|
|
|
|
{
|
|
|
|
|
ServerListener server = new ServerListener();
|
|
|
|
|
server.OnGameServerConnecting += OnClientConnecting;
|
|
|
|
|
server.OnGameServerConnected += OnGameServerConnected;
|
|
|
|
|
server.OnGameServerDisconnected += OnGameServerDisconnected;
|
|
|
|
|
server.Start(29294);
|
2023-03-03 15:15:17 +03:00
|
|
|
|
|
2023-03-03 23:00:54 +03:00
|
|
|
|
Thread.Sleep(-1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Client c = new Client("127.0.0.1", 29294);
|
|
|
|
|
c.ServerName = "Test Server";
|
|
|
|
|
c.Gamemode = "TDP";
|
|
|
|
|
c.Map = "DustyDew";
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
c.Tick();
|
|
|
|
|
Thread.Sleep(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-03 15:15:17 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task<bool> OnClientConnecting(IPAddress ip)
|
|
|
|
|
{
|
2023-03-03 23:00:54 +03:00
|
|
|
|
Console.WriteLine(ip + " is connecting.");
|
2023-03-03 15:15:17 +03:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
private static async Task OnGameServerConnected(GameServer server)
|
|
|
|
|
{
|
2023-03-03 23:00:54 +03:00
|
|
|
|
Console.WriteLine("Server " + server.ServerName + " was connected.");
|
2023-03-03 15:15:17 +03:00
|
|
|
|
}
|
|
|
|
|
private static async Task OnGameServerDisconnected(GameServer server)
|
|
|
|
|
{
|
2023-03-03 23:00:54 +03:00
|
|
|
|
Console.WriteLine("Server " + server.ServerName + " was disconnected. (" + server.TerminationReason + ")");
|
2023-03-03 15:15:17 +03:00
|
|
|
|
}
|
|
|
|
|
}
|