示例#1
0
        private static TipoStato CreateMsgIng(string strMsg, TipoStato stato, out Messaggio msg)
        {
            msg = MessaggioFactory.Create(strMsg);
            TipoComando ingresso        = (TipoComando)Enum.Parse(typeof(TipoComando), strMsg.Split(' ')[0], true);
            Ingresso    ing             = IngressoFactory.Create(ingresso);
            TipoStato   statoSuccessivo = ing.CambiaStato(stato);

            return(statoSuccessivo);
        }
示例#2
0
        private void btnPeop1_Click(object sender, RoutedEventArgs e)
        {
            string    peop1 = "peop " + txtPeop1.Text;
            Messaggio msg   = MessaggioFactory.Create(peop1);

            if (msg == null)
            {
                MessageBox.Show("Errore", "Messaggio sconosciuto");
                sw.WriteLine("-ERR");
            }
        }
示例#3
0
        private void btnBirtPeop1_Click(object sender, RoutedEventArgs e)
        {
            DateTime  Birth1 = (DateTime)Birt1.SelectedDate;
            string    date1  = "birth " + Birth1.ToString();
            Messaggio msg    = MessaggioFactory.Create(date1);

            if (msg == null)
            {
                MessageBox.Show("Errore", "Messaggio sconosciuto");
                sw.WriteLine("-ERR");
            }
        }
示例#4
0
        static void Comunica(object param)
        {
            TcpClient client = (TcpClient)param;

            Console.WriteLine("Sto avviando la comunicazione");
            NetworkStream nsRead  = client.GetStream();
            NetworkStream nsWrite = client.GetStream();

            StreamReader sr = new StreamReader(nsRead);
            StreamWriter sw = new StreamWriter(nsWrite);

            sw.AutoFlush = true;
            try
            {
                while (true)
                {
                    // lettura richiesta dal client
                    string str = sr.ReadLine();
                    Console.WriteLine(str);
                    // Elaborazione e invio risposta
                    Messaggio msg = MessaggioFactory.Create(str);
                    if (msg != null)
                    {
                        Console.WriteLine(msg.GetType().ToString());
                        sw.WriteLine("+OK");
                    }
                    else
                    {
                        Console.WriteLine("Messaggio sconosciuto");
                        sw.WriteLine("-ERR");
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Messaggio sconosciuto");
                sw.WriteLine("-ERR");
            }
        }