Exemple #1
0
        void GamePool()
        {
            Player1.Send("1");
            Player2.Send("1");
            byte[] Buffer1 = new byte[26];
            byte[] Buffer2 = new byte[26];

            while (true)
            {
                try
                {
                    int P1Pos = Player1.Client.ns.Read(Buffer1, 0, Buffer1.Length);
                    int P2Pos = Player2.Client.ns.Read(Buffer2, 0, Buffer2.Length);

                    Player1.Client.ns.Write(Buffer2, 0, P2Pos);
                    Player2.Client.ns.Write(Buffer1, 0, P1Pos);
                }
                catch {
                    Player1.Dispose();
                    Player2.Dispose();
                    Games.Remove(this);
                    GamePoolThread.Abort();
                }
            }
        }
Exemple #2
0
        public BounceGame(Client P1, NotificableClient NotificableP2, List <Game> Games, string Username)
        {
            this.Games = Games;
            Player1    = new BounceGame_Player(P1);

            Thread TimeOut = new Thread(() =>
            {
                while (this.Player2 == null)
                {
                    Thread.Sleep(1000);
                }
            });

            TimeOut.Start();

            new Thread(() => {
                if (!TimeOut.Join(TimeSpan.FromSeconds(20)))
                {
                    Player1.Dispose();
                    Games.Remove(this);
                }
            }).Start();

            NotificableP2.Send(new string[] { _Details.GameInvitation_Bounce, base.GameId, Username });
        }