using System.Net; using System.Net.Sockets; namespace Tiger.Networking.Game; public abstract class TcpServer { protected readonly TcpListener Server; protected TcpServer(string ip, int port) { Server = new TcpListener(IPAddress.Parse(ip), port); } public virtual void Start() { Server.Start(); AcceptClients(); } private async void AcceptClients() { while (true) { var client = await Server.AcceptTcpClientAsync(); _ = ConnectionCallbackAsync(client); } } protected abstract Task ConnectionCallbackAsync(TcpClient client); }