using System.Net;
using System.Net.Sockets;

namespace Helix.Mud
{
    public class Server
    {
        public async void Run()
        {
            var localAddr = IPAddress.Parse("0.0.0.0");
            var server = new TcpListener(localAddr, 8080);

            server.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
            server.Start();

            while (true)
            {
                var client = await server.AcceptTcpClientAsync();
                var connection = new Connection(client);

                connection.Handle();
            }
        }
    }
}
