Esempio n. 1
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;
 }
Esempio n. 2
0
 private void printMessage(MessageArgs message)
 {
     Console.WriteLine(message.getName() + ": " + message.getMessage());
 }
Esempio n. 3
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;
     }
 }