Exemplo n.º 1
0
        //Méthode pour envoier les plats prets via un TcpClient
        public void SendDishs(DishReady readyDishes)
        {
            try
            {
                //récupérer le type des dishs et les dish (en string) pour le mettre dans une liste
                List <string> dishes = new List <string>();
                dishes.Add(readyDishes.IdOrder.ToString());
                dishes.Add(readyDishes.Nom);

                //Instanciation du TcpClient
                TcpClient client = new TcpClient(ServerIp, Port);

                //Envois de la commande au server TcpListener via NetworkStream en utilisant BinaryFormatter
                using (NetworkStream ns = client.GetStream())
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    bf.Serialize(ns, dishes);
                }
                Console.WriteLine("Commande " + dishes[0] + " dish envoyé ----" + dishes[1] + " --- \n");
                //on stope le TcpClient
                client.Close();
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("ArgumentNullException: {0}", e);
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
        }
Exemplo n.º 2
0
        public void PrepareReady(Order order)
        {
            IsAvailable = false;

            DishReady dishReady = new DishReady(order.IdOrder, "plats");

            Kitchen.Instance.CounterDishes.DishReadies.Add(dishReady);

            Thread.Sleep(1000);

            Console.WriteLine("Commande prête");
            this.IsAvailable = true;
        }
Exemplo n.º 3
0
 //thread du headWaiter
 public void SocketDishesWorkThread()
 {
     while (true)
     {
         if (DishReadies.Count() > 0)
         {
             DishReady dishes = DishReadies.First();
             SendDishs(dishes);
             DishReadies.Remove(dishes);
         }
         else
         {
             Thread.Sleep(1000);
         }
         Thread.Sleep(1000);
     }
 }