Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _server = new Server();

            _networkGame = new NetworkGame(_server);

            _server.StartServer(_networkGame);


            base.Initialize();
        }
Ejemplo n.º 2
0
        public void StartServer(NetworkGame pNetworkGame)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("Game 2")
            {
                Port = 8080
            };

            config.EnableUPnP = true;

            _server = new NetServer(config);
            _server.Start();
            Console.WriteLine("Server is active");
            checkForMessages();

            netGame1 = pNetworkGame;

            // attempt to forward port 14242
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            //_server.UPnP.ForwardPort(8080, "Text detail here");

            ConnectionDic = new Dictionary <long, NetConnection>();
        }