示例#1
0
文件: Form2.cs 项目: TheTOXIN/CChat
        private void button1_Click(object sender, EventArgs e)
        {
            string token = "";
            string pas   = textBox2.Text.Trim();
            string log   = textBox1.Text.Trim();

            if (Utill.validateLogin(log, pas))
            {
                User user = new User(log, pas);
                token = Utill.getHesh(log, pas);

                con.setInfo(textBox4.Text, textBox3.Text);
                con.getConnect();

                if (!checkBox1.Checked)
                {
                    con.sender(Utill.LOG + token);
                }
                else
                {
                    con.sender(Utill.NEW + Mapper.toString(user));
                }

                string answer = con.receiver();

                if (answer.Equals(Utill.CON))
                {
                    label1.Text      = "CONNECT";
                    label1.ForeColor = Color.Green;
                    Program.user     = user;
                    this.Hide();
                    form = new Form1();
                    form.StartPosition = this.StartPosition;
                    form.Show();
                }
                else if (answer.Equals(Utill.DIS))
                {
                    label1.Text      = "WRONG";
                    label1.ForeColor = Color.Red;
                }
            }
            else
            {
                label1.Text      = "INVALID";
                label1.ForeColor = Color.Yellow;
            }
        }
示例#2
0
文件: User.cs 项目: TheTOXIN/CChat
 public User(string nickname, string password)
 {
     this.nickname = nickname;
     this.password = password;
     this.token    = Utill.getHesh(nickname, password);
 }