Example #1
0
 private void SendMessages()
 {
     while (true)
     {
         lock (mutex)
         {
             List <RMessage> newMessageQueue = new List <RMessage>();
             foreach (RMessage m in messageQueue)
             {
                 try
                 {
                     --timeout[m];
                     WireMessage.SendMessage(tcpClient, m);
                     timeout.Remove(m);
                 }
                 catch (Exception)
                 {
                     if (timeout[m] > 0)
                     {
                         newMessageQueue.Add(m);
                     }
                     else
                     {
                         // Send back the message
                         Context.FireCallback(m);
                         timeout.Remove(m);
                     }
                 }
             }
             messageQueue.Clear();
             messageQueue.AddRange(newMessageQueue);
         }
         Thread.Sleep(DELAY_TIME);
     }
 }
Example #2
0
 public void SendMessage(RMessage message)
 {
     try
     {
         WireMessage.SendMessage(connection, message);
     }
     catch (Exception)
     {
         // The connection is down, we destroy this ClientWorker
         CloseConnection();
         chatThread.Abort();
     }
 }