Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Gateway");
            // Console.WriteLine("  Press L to login (auto login is set).");
            // Console.WriteLine("  Press P to update player position.");
            Console.WriteLine("  Press esc to exit.\n\n");

            bool testAgainstRealLoginServer      = false;
            SocketWrapperSettings socketSettings = null;

            if (testAgainstRealLoginServer)
            {
                socketSettings = new SocketWrapperSettings("localhost", 11002);
            }
            LoginServerProxy loginServer = new LoginServerProxy(socketSettings);
            GatewayMain      gateway     = new GatewayMain(loginServer);

            gateway.SetMaxFPS(NetworkConstants.GatewayFPS);
            loginServer.StartService();
            gateway.StartService();

            ConsoleKey key;

            do
            {
                while (!Console.KeyAvailable)
                {
                    Thread.Sleep(20);
                }
                key = Console.ReadKey(true).Key;
            } while (key != ConsoleKey.Escape);
            loginServer.Cleanup();
            gateway.Cleanup();
        }
Ejemplo n.º 2
0
        public GatewayMain(LoginServerProxy loginServer) : base()
        {
            servers         = new ServerRegistry();
            players         = new List <GatewayPlayer>();
            inactivePlayers = new List <GatewayPlayer>();

            loginServerProxy = loginServer;
            loginServerProxy.OnNewPlayerLoggedIn += NewPlayerLoginResult;

            playerConnectionListener = new ListenServer(NetworkConstants.defaultGatewayToClientPort, "0.0.0.0", "client-side");
            playerConnectionListener.OnNewConnection += OnNewPlayerConnection;

            serverListener = new ListenServer(NetworkConstants.defaultGatewayToServerPort, "0.0.0.0", "server-side");
            serverListener.OnNewConnection += OnNewServerConnection;

            Console.WriteLine("-------------------------------------------------------");
            newServersAwaitingConfirmation = new List <ServerConnectionState>();
            newPlayersAwaitingConfirmation = new List <PlayerConnectionState>();

            serverListener.StartListening();
            playerConnectionListener.StartListening();
            screenRefreshTimer = new Stopwatch();
            screenRefreshTimer.Start();
        }