Beispiel #1
0
 private void SendMessageList(string teamId, bool useMulticast)
 {
     object[] messages;
     lock (_messageQueue.SyncRoot)
     {
         messages = _messageQueue.ToArray();
     }
     List<CommunicationMessage> messagesToSend = new List<CommunicationMessage>();
     int numberSend = 0;
     for (int i = messages.Length - 1; i >= 0; i--)
     {
         CommunicationMessage message = (CommunicationMessage)messages[i];
         if (string.IsNullOrEmpty(message.GetTeamId()) || message.GetTeamId().Equals(teamId, StringComparison.OrdinalIgnoreCase))
         {
             CommunicationMessage newMessage = new CommunicationMessage(message.Data);
             newMessage.SetTeamId(teamId);
             newMessage.IsMulticast = useMulticast;
             newMessage.SetSynchronizedFlag();
             messagesToSend.Add(newMessage);
             numberSend++;
             if (numberSend >= 50)
             {
                 break;
             }
         }
     }
     for (int i = messagesToSend.Count-1; i >= 0 ; i--)
     {
         _server.Enqueue(messagesToSend[i]);
     }
 }