Esempio n. 1
0
        static void Main(string[] args)
        {
            IPAddress ipAddr = IPAddress.Parse("127.0.0.1");
            Listener listener = new Listener(new TcpListener(ipAddr, 10060));
            ClientManager clientManager = new ClientManager();
            GameManager gameManager = new GameManager();

            new Server(listener, clientManager, gameManager).Start();

            Console.WriteLine("Running on {0}:10060", ipAddr.ToString());
            Console.ReadKey();
        }
Esempio n. 2
0
        //constructors
        public Server(Listener listener, ClientManager clientManager, GameManager gameManager)
        {
            this.listener = listener;
            this.clientManager = clientManager;
            this.gameManager = gameManager;

            messager = new SocketMessageTransmitter();
            protocol = new Protocol();
            notifier = new Notifier(protocol);
            loginEventRiser = new LoginEventRiser();

            loginEventRiser.ConnectEvent += Connect;
            listener.NewConnection += NewConnection;
            clientManager.NewGame += NewGame;
            gameManager.GameOverEvent += GameOver;
            gameManager.FreeUserEvent += clientManager.AddClient;
        }