mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-13 06:54:48 +01:00
remove tcp GameServer and rename SDKServer
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
using System.Net.Sockets;
|
||||
using System.Net;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
using Novaria.GameServer.Protocol;
|
||||
|
||||
namespace Novaria.GameServer
|
||||
{
|
||||
public class GameServer
|
||||
{
|
||||
private readonly TcpListener listener;
|
||||
|
||||
private static GameServer _instance;
|
||||
public static readonly int GameServerPort = 6969;
|
||||
|
||||
public static GameServer Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance ??= new GameServer();
|
||||
}
|
||||
}
|
||||
|
||||
public GameServer()
|
||||
{
|
||||
listener = new(IPAddress.Parse("0.0.0.0"), GameServerPort);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
listener.Start();
|
||||
|
||||
Log.Information($"{nameof(GameServer)} started and listening on port {GameServerPort}");
|
||||
|
||||
while (true)
|
||||
{
|
||||
TcpClient tcpClient = listener.AcceptTcpClient();
|
||||
string id = tcpClient.Client.RemoteEndPoint!.ToString()!;
|
||||
|
||||
Log.Information($"{id} connected");
|
||||
|
||||
Task.Run(() => HandleMessage(tcpClient));
|
||||
}
|
||||
} catch (Exception ex)
|
||||
{
|
||||
Log.Information("TCP listener error: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void HandleMessage(TcpClient tcpClient)
|
||||
{
|
||||
Connection connection = Connection.CreateConnection(tcpClient);
|
||||
|
||||
connection.HandleMessage(tcpClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user