Esempio n. 1
0
        void ReceiveData()
        {
            while (true)
            {
                string output = "";

                if (netStream.DataAvailable)
                {
                    StreamReader sr = new StreamReader(netStream);
                    output = sr.ReadLine();
                    string[] msg = output.Split(',');
                    switch (msg[0])
                    {
                    case "loginsuccess":
                        playersList.lb_name.Text = msg[1];
                        Thread thread = new Thread(new ThreadStart(mf.pl.ShowForm));
                        mf.Hide();
                        mf.rf.Hide();
                        thread.Start();
                        break;

                    case "loginrefuse":
                        MessageBox.Show("Incorrect login or pass");
                        break;

                    case "list":
                        playersList.AddList(msg);
                        break;

                    case "invite":
                        AskRequest ar = new AskRequest(msg[1], msg[2], msg[3], netStream, playersList);
                        Thread     tr = new Thread(new ThreadStart(ar.ShowForm));
                        tr.Start();
                        break;

                    case "ask":
                        if (msg[1] == "XO")
                        {
                            game = new GameXO(netStream, playersList.name);
                            Thread tr1 = new Thread(new ThreadStart(game.ShowForm));
                            tr1.Start();
                        }
                        break;

                    case "gamexo":
                        game.ReceiveGameData(output);
                        break;
                    }
                }
                Thread.Sleep(100);
            }
        }
Esempio n. 2
0
        void ReceiveData()
        {
            while (true)
            {
                string output = "";

                StreamReader sr = new StreamReader(netStream);
                output = sr.ReadLine();
                string[] msg = output.Split(',');
                switch (msg[0])
                {
                case "name":

                    playersList.lb_name.Text = msg[1];
                    break;

                case "list":
                    playersList.AddList(msg);
                    break;

                case "invite":


                    AskRequest ar = new AskRequest(msg[1], msg[2], msg[3], netStream, playersList);
                    Thread     tr = new Thread(new ThreadStart(ar.ShowForm));
                    tr.Start();



                    break;

                case "ask":
                    if (msg[1] == "XO")
                    {
                        game = new GameXO(netStream, playersList.name);

                        Thread tr1 = new Thread(new ThreadStart(game.ShowForm));
                        tr1.Start();
                    }
                    break;

                case "gamexo":
                    game.ReceiveGameData(output);

                    break;
                }
            }
        }