示例#1
0
        public static object ReadAndDeserialize(NetworkStream ns)
        {
            IFormatter formatter = new BinaryFormatter();

            try
            {
                return(formatter.Deserialize(ns));
            }
            catch (Exception e)
            {
                LogConsole.Log(e.Message);
            }
            return(null);
        }
示例#2
0
        private void StartGame()
        {
            NetworkStream StreamJ1 = Joueur1.GetStream();
            NetworkStream StreamJ2 = Joueur2.GetStream();

            PosShips GrilleJ1;
            PosShips GrilleJ2;


            LogConsole.Log("Début Partie");

            ConnUtility.SerializeAndSend(StreamJ1, "Start");
            ConnUtility.SerializeAndSend(StreamJ2, "Start");

            StreamJ1.ReadTimeout = StreamJ2.ReadTimeout = 60000;
            try
            {
                LogConsole.Log("Lecture 1 ");
                GrilleJ1 = (PosShips)ConnUtility.ReadAndDeserialize(StreamJ1);
                LogConsole.Log("Lecture 2 ");
                GrilleJ2 = (PosShips)ConnUtility.ReadAndDeserialize(StreamJ2);
                LogConsole.Log("Tentative Lecture");
                LogConsole.Log(GrilleJ1.PPorteAvion.ToString());
                LogConsole.Log(GrilleJ2.PPorteAvion.ToString());
            }
            catch (Exception e)
            {
                LogConsole.Log("Erreur réception grille Erreur: " + e.Message);
            }



            /*recevoir tableau*/

            /*partir boucle Joueur1*/
            //jeu.Abort();
            while (true)
            {
                Thread.Sleep(500);
            }

            MatchMakingServeur.GameInstances.Remove(this);
        }