public void recievePacketChat(PacketChat chat)
        {
            //append text to the App form
            //this.client.appendTextToChat("[dokter] " + chat.messageText + Environment.NewLine);

            List<Client> clients = this.client.clients;

            foreach (Client client in clients)
            {
                if (client.Identifier.Id == chat.destinationID)
                {
                    client.Panel.changeChatBoxText("[dokter] " + chat.messageText + Environment.NewLine);
                }
            }
        }
 public void recievePacketChat(PacketChat chat)
 {
     //append text to the App form
     this.client.appendTextToChat("[doctor] " + chat.messageText);
 }
Esempio n. 3
0
        private void textBox8_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Chatbox.AppendText("[you] " + this.Sendbox.Text + Environment.NewLine);

                //send packet to the server
                PacketChat chat = new PacketChat(this.Sendbox.Text + Environment.NewLine, hostName, "monitor", id);
                this.serverConnection.WritePacket(chat);
                Console.WriteLine("Sent message");
                Sendbox.Clear();
            }
        }
 public void receiveChatPacket(PacketChat chat)
 {
     if (chat.destination == "monitor")
     {
         _server.sendPackToMonitor(chat);
         Console.WriteLine("Sent Pack to monitor");
     }
     else
     {
         _server.sendPacketToClient(chat, chat.destinationID);
         Console.WriteLine("Sent Pack to client");
     }
 }
Esempio n. 5
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == Keys.Enter && ReturnActualPowerTextBox().Focused)
     {
         ReturnChatInputTextBox().Select();
         RPMTextbox.Text = "text";
     }
     if (keyData == Keys.Enter && ReturnChatInputTextBox().Focused)
     {
         ReturnChatInputTextBox().Select();
         string chatText = ReturnChatInputTextBox().Text;
         changeChatBoxTextSelf(chatText);
         PacketChat chat = new PacketChat(chatText, id.Username, "client", id.Id);
         connection.writePacket(chat);
         chatInputTextBox.Clear();
         return true;
     }
     return base.ProcessCmdKey(ref msg, keyData);
 }
        public void recieveChat(PacketChat pack)
        {
            Console.WriteLine("Recieved Chat Packet");

            form.Invoke((Action)(() =>
            {
                try
                {
                    form.showMessage(pack.destinationID, pack.messageText);
                }
                catch
                (Exception e)
                {
                    Console.WriteLine(e.Message);
                    //MessageBox.Show("No connection to the server");
                    //form.closeApplicaton();
                }
            }));
        }