Esempio n. 1
0
        public override void Update(GameTime gameTime)
        {
            reciever.Recieve();

            if (reciever.Connected == true)
            {
                reciever.Send();
                if (Time.TotalGameTime.Subtract(reciever.lastHeardFrom).CompareTo(NetConstants.TIMEOUT_TIME) > 0)
                {
                    OnDisconnect("Connection to server lost!\nPress escape to return to the main menu!");
                    reciever.Stop();
                }
            }


            base.Update(gameTime);
        }
Esempio n. 2
0
        protected override void AfterManagerPreStageUpdate(GameTime time)
        {
            if (reciever != null)
            {
                reciever.Recieve();
                reciever.Send();
            }
            else if (sender != null)
            {
                if (startDebug == true)
                {
                    new Vector2();
                }

                sender.UpdateCurrentState();
                sender.SendToAll();
            }
            else
            {
                if (Input.KeyDown(Keys.F1))
                {
                    sender = new NetManagerSender(25565);
                    stage.CreateActor(0).AddComponent <ServerConnectionComponent>().Set(playerSpawns, "Unknown", stage);
                }
                else if (Input.KeyDown(Keys.F2))
                {
                    reciever = new NetManagerReciever(new IPEndPoint(IPAddress.Parse("0:0:0:0:0:0:0:1"), 25565), "Unknown");
                    stage.CreateActor(0).AddComponent <ClientConnectionComponent>();
                }
            }

            if (Input.KeyDown(Keys.F5))
            {
                startDebug = true;
            }
        }