Ejemplo n.º 1
0
        private void CommandRecieved(object sender, CommandEventArgs e)
        {
            if (e.Command.CommandType == CommandType.UserDataInform)
            {
                client.Wins = int.Parse(e.Command.Data.Split(':')[0]);
                client.Losses = int.Parse(e.Command.Data.Split(':')[1]);
            }
            if (e.Command.CommandType == CommandType.UsernameRequest)
            {
                if (e.Command.Data.ToLower() == "false")
                {
                    client.SignOut();
                    MessageBox.Show("Username already in use!", "Invalid Username", MessageBoxButtons.OK);
                    client.Disconnect();

                }
                else if (e.Command.Data.ToLower() == "true")
                {
                    client.CommandRecieved -= CommandRecieved;
                    if (InvokeRequired)
                    {
                        BeginInvoke(new MethodInvoker(delegate
                      {
                          chat = new ChatForm(ref client, this);
                          chat.Show();
                          Hide();
                      }));
                    }
                    else
                    {
                        chat = new ChatForm(ref client, this);
                        chat.Show();
                        Hide();
                    }
                }
            }
        }