Example #1
0
 public void Message_Received_Event(MessageArgs message)
 {
     if (message.getMessage().Equals("quit"))
     {
         this.disconnect();
         this.connected = false;
     }
     else
         printMessage(message);
 }
Example #2
0
        public void sendMessage(MessageArgs message)
        {
            bytes = new byte[1024];
            data = null;
            bytes = Encoding.ASCII.GetBytes(message.getMessage());
            stream.Write(bytes, 0, bytes.Length);

            if(Message_Sent != null)
                Message_Sent(message);
        }
Example #3
0
 private void printMessage(MessageArgs message)
 {
     Console.WriteLine(message.getName() + ": " + message.getMessage());
 }
Example #4
0
 public void Message_Sent_Event(MessageArgs message)
 {
     printMessage(message);
 }
Example #5
0
 public void Client_Disc_Event(MessageArgs message)
 {
     printMessage(message);
 }
Example #6
0
 public void Client_Conn_Event(MessageArgs message)
 {
     printMessage(message);
 }
Example #7
0
 /// <summary>
 /// The primary function dealing with updating the client UI
 /// </summary>
 /// <param name="message"></param>
 private void Message_Sent_Event(MessageArgs message)
 {
     this.rtbChat.AppendText(message.getName() + ": " + message.getMessage() + Environment.NewLine);
     tbMessage.Text = placeholder;
 }
Example #8
0
 /// <summary>
 /// Events
 /// Message and client events handled here
 /// </summary>
 /// <param name="message"></param>
 private void Message_Received_Event(MessageArgs message)
 {
     if (message.getMessage().Equals("quit"))
     {
         this.connected = false;
         this.client.disconnect();
     }
         ///Thread saftey dance
     else if(this.rtbChat.InvokeRequired)
     {
         ///Set the address of this function into the null delegate ts_
         ///Then run ts_ (Recieved_Event) on the thread that owns
         ///The windows form handle of this.rtbChat (Invoke)
         this.rtbChat.Invoke(new ts_Message_Recieved_Event(this.Message_Received_Event), message);
     }
         ///When ts_ executes on the handle's native thread
         ///this else will run and the text will get outputted as normal
     else
     {
         this.rtbChat.AppendText(message.getName() + ": " + message.getMessage() + Environment.NewLine);
         this.rtbChat.ScrollToCaret();
         if (!this.connected)
             this.tbMessage.Enabled = false;
     }
 }
Example #9
0
 /// <summary>
 /// The method called by public implementations like the chat app
 /// In order to send a message over TCP
 /// </summary>
 /// <param name="message"></param>
 public void sendMessage(MessageArgs message)
 {
     this.writeStream(message.getMessage());
     if(Message_Sent != null)
         Message_Sent(message);
 }