Exemplo n.º 1
0
 /// <summary>
 /// Place a message in the queue for distribution.  The queued message will be picked up by
 ///  DistributeMessagePump via DequeuMessagePackage. 
 ///  Queue access is synchronized to avoid simultaneous access by EnqueueMessagePackage and DequeueMessagePackage
 /// </summary>
 /// <param name="messageBody"></param>
 /// <param name="messageLen"></param>
 /// <param name="senderIP"></param>
 /// <param name="destinationIP"></param>
 protected void EnqueueMessagePackage(byte[] messageBody, int messageLen, IPAddress senderIP, IPAddress destinationIP)
 {
     MessagePackage package = new MessagePackage(messageBody, messageLen, senderIP, destinationIP);
     lock (_distQueue)
     {
         _distQueue.Enqueue(package);
     }
     // Notify that data has arrived
     Win32.SetEvent(_distQEventHandle);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Iterate through the list of clients sending the message to each except for the
 /// one that originally sent the message.  
 /// Actual sending of the message is handled by DoSendDetails
 /// </summary>
 /// <param name="package"></param>
 protected void DistributePackage(MessagePackage package)
 {
     try
     {
         //ArrayList clients = _clientList.
         foreach (IPEndPoint ipClientEP in _clientList)
         {
             // Don't send it back to the one who sent it
             if (!ipClientEP.Address.Equals(package.senderIP))
             {
                 DoSendDetails(package.messageBody, package.messageLen, ipClientEP);
             }
         }
     }
     catch (Exception ex)
     {
         ;
     }
 }