Exemplo n.º 1
0
        private void submenu_Login_Click(object sender, EventArgs e)
        {
            if (submenu_Login.Text == "Login")
            {
                LoginScreen login = new LoginScreen(IPAddress.Parse("127.0.0.1"), 8000);
                login.ShowDialog();
                client = login.Client;

                if (client.Connected)
                {
                    client.received += new CommandReceivedEventHandler(clientCommandReceived);
                    client.SendCommand(new Command(type.test, IPAddress.Broadcast, client.ClientIP + ":" + client.NetName));
                    client.SendCommand(new Command(type.SendClientList, client.serverIP));
                    AddToList(client.ClientIP.ToString(), client.NetName);
                    submenu_Login.Text = "Log Off";
                }
            }
            else
            {
                submenu_Login.Text = "Login";
                chatList.Clear();
                client.Disconnect();
                listView_Users.Items.Clear();
                txtBox_MessageToSend.Clear();
                txtBox_MessageToSend.Focus();
            }
        }
Exemplo n.º 2
0
 //sends message to the chatroom
 private void SendMessage()
 {
     if (client.Connected && txtBox_MessageToSend.Text.Trim() != "")
     {
         client.SendCommand(new Command(type.Message, IPAddress.Broadcast, txtBox_MessageToSend.Text));
         txtBox_Chatroom.Text     += client.NetName + ": " + txtBox_MessageToSend.Text.Trim() + Environment.NewLine;
         txtBox_MessageToSend.Text = "";
         txtBox_MessageToSend.Focus();
     }
 }
Exemplo n.º 3
0
 //send a message to the target client
 private void SendMessage()
 {
     if (targetClient.Connected && txtBox_PrivateMsg.Text.Trim() != "")
     {
         targetClient.SendCommand(new Command(type.Message, targetIP, txtBox_PrivateMsg.Text));
         txtBox_PrivateChat.Text += targetClient.NetName + ": " + txtBox_PrivateMsg.Text.Trim() + Environment.NewLine;
         txtBox_PrivateMsg.Text   = "";
         txtBox_PrivateMsg.Focus();
     }
 }
Exemplo n.º 4
0
 private void client_ConnectingSuccess(object sender, EventArgs e)
 {
     client.SendCommand(new Command(type.IsNameExists, client.ClientIP, client.NetName));
 }