Esempio n. 1
0
        //Tin nhan rieng giua 2 client
        void PrivateMess(string[] cmd)
        {
            string pfrom = cmd[1]; //gui tu
            string pto   = cmd[2]; // gui den

            if (pto == user)       //kiểm tra xem có đúng là tin nhắn gửi tới mình hay không
            {
                var value = listuChat.SingleOrDefault(r => r.To() == cmd[1]);
                if (value != null)
                {
                    value.richTextBox1.Text += cmd[1] + " : " + cmd[3] + "\r\n";
                }
                else
                {
                    this.Invoke(() =>
                    {
                        uChat = new PrivateUser(this);
                        uChat.SetFrom(pto);
                        uChat.SetTo(pfrom);
                        uChat.Text = "From :" + pto + ":To:" + pfrom;
                        uChat.Show();
                        checkuChat = false;
                        listuChat.Add(uChat);
                        uChat.richTextBox1.Text += cmd[1] + " : " + cmd[3] + "\r\n";
                    });
                }
                //}
            }
        }
Esempio n. 2
0
        //Chat rieeng giua 2 client
        private void privateChatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string to = UserList.SelectedItem.ToString();

            if (to != null)
            {
                if (to != user) // dam bao khong chat voi chinh minh
                {
                    SendData("PRIVATECHAT|" + user + "|" + to);
                    var value = listuChat.SingleOrDefault(r => r.To() == to);
                    if (value != null)
                    {
                        value.Show();
                    }
                    else
                    {
                        uChat = new PrivateUser(this);
                        uChat.SetFrom(user); // set thuoc tinh nguoi gui
                        uChat.SetTo(to);     // set thuoc tinh nguoi nhan
                        uChat.Text = "From :" + user + ":To:" + to;
                        uChat.Show();
                        checkuChat = false;
                        listuChat.Add(uChat);
                    }
                }
            }
        }
Esempio n. 3
0
        //Nhan yeu cau chat rieng tu tu client khac
        void RequestPrivateClient(string[] cmd)
        {
            string fromUser = cmd[1];
            string toUser   = cmd[2];

            if (toUser == user)
            {
                var value = listuChat.SingleOrDefault(r => r.From() == cmd[2]); // kiem tra xem co ton tai form nao chua
                if (value == null)
                {
                    this.Invoke(() =>
                    {
                        uChat = new PrivateUser(this);
                        uChat.SetFrom(toUser);
                        uChat.SetTo(fromUser);
                        uChat.Text = "From :" + toUser + ":To:" + fromUser;
                        uChat.Show();
                        listuChat.Add(uChat);
                    });
                }
                else
                {
                    value.Show();
                }
            }
        }