Ejemplo n.º 1
0
 private void SendBtn_Click(object sender, EventArgs e)
 {
     MessageShow.AppendText(username + ":" + SendText.Text + Environment.NewLine);
     li.Add(DateTime.Now.ToString("MM-dd-yyyy,HH:mm"));
     try
     {
         UdpChat.SendMessage(username + ":" + SendText.Text);
         SendText.Text = "";
     }
     catch (Exception) {
         SendText.Text = "";
     }
 }
Ejemplo n.º 2
0
        public void MessageJudgment(string message)
        {
            if (message.StartsWith("Online"))
            {
                if (message.Substring(6) == ChatRoom.username)
                {
                    udpchat.SendMessage("ISREPEAT");
                }
                else
                {
                    Addusername.Invoke(message.Substring(6));
                    chatRoom.AdddUserNAME(message.Substring(6));
                    otherUser = message.Substring(6);
                    udpchat.SendMessage("Respones" + ChatRoom.username);
                }
            }
            else if (message.StartsWith("Offline"))
            {
                cancelName.Invoke();
            }
            else if (message.StartsWith("Respones"))
            {
                Addusername.Invoke(message.Substring(8));
            }
            else if (message.StartsWith("ISREPEAT"))
            {
                Login lg = new Login();

                repeatName.Invoke();
                MessageBox.Show("Repeat Name!!");

                lg.Owner = chatRoom;

                if (lg.ShowDialog(chatRoom) == DialogResult.OK)
                {
                    ChatRoom.username = lg.GetName();
                    chatRoom.SetText(ChatRoom.username);
                    udpchat.SendMessage("Online" + ChatRoom.username);
                }
                else
                {
                    //_button.Enabled = true;
                }
            }
            else
            {
                addHistory.Invoke(message);
            }
        }
Ejemplo n.º 3
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            Login loginForm = new Login();

            loginForm.Owner = this;

            if (loginForm.ShowDialog(this) == DialogResult.OK)
            {
                UdpChat = new UdpChat(loginForm.port1, loginForm.port2);

                messageCheck             = new MessageCheck(UdpChat);
                messageCheck.Addusername = AdddUserNAME;
                messageCheck.cancelName  = CancelUserName;
                messageCheck.repeatName  = RepeatUserName;
                messageCheck.addHistory  = AddTextHistory;
                UdpChat.messageCheck     = messageCheck;

                UdpChat.ReceiveStart();

                UdpChat.SendMessage("Online" + username);

                LoginBtn.Enabled = false;
                BtnUpdate();
                onlineStatus = true;
                //TODO: Login -> Username.
            }
            else
            {
                LoginBtn.Enabled = true;
                BtnUpdate();
            }
        }