Beispiel #1
0
 public void sendStuff()
 {
     while (running)
     {
         if (outQ.Count != 0)
         {
             Envelope check;
             if (outQ.TryPeek(out check) && check.isTcp) //Note: if udp message are not being send this could block up the TCP communicator.
             {
                 Envelope toSend;
                 if (outQ.TryDequeue(out toSend))
                 {
                     this.send(toSend);
                 }
             }
             else
             {
                 outQ.setQueueSignal(); //Marks send in someone else to get the message that was not meant for TCP.
                 Thread.Sleep(300);     //Wait a little for other communicator to pick it up.
             }
         }
         else
         {
             outQ.waitIncomingEnv(); //Waits for something to come into the queue
         }
     }
 }
 //Takes stuff off outQ and send it to where it should go.
 private void sendStuff()
 {
     while (running)
     {
         if (outQ.Count != 0)
         {
             Envelope check;
             if (outQ.TryPeek(out check) && !check.isTcp) //Note: This will cause the UDPcommunicator to become backed up if the TCP communicator is not taking things off this queue.
             {
                 Envelope toSend;
                 if (outQ.TryDequeue(out toSend))
                 {
                     this.send(toSend);
                 }
             }
             else
             {
                 outQ.setQueueSignal(); //Sets the queue again stating that nothing was taken out.
                 Thread.Sleep(100);     //Wait a little for other communicator to pick it up.
             }
         }
         else
         {
             outQ.waitIncomingEnv(); //Waits for something to enter the inQ.
         }
     }
 }
 //Takes stuff of inQ and sends it to where it should go.
 private void recieveStuff()
 {
     while (running)
     {
         Envelope recieved = recieve();
         inQ.Enqueue(recieved);
         inQ.setQueueSignal();
     }
 }
Beispiel #4
0
 public void recieveStuff()
 {
     while (running)
     {
         foreach (KeyValuePair <IPEndPoint, TcpClient> client in tcpClients)
         {
             Envelope env = recieve(client.Key);
             if (env != null)
             {
                 inQ.Enqueue(env);
                 inQ.setQueueSignal();
             }
         }
         Thread.Sleep(300); //Take a 200ms snoozer. //Not sure how to add a event for this.
     }
 }