Пример #1
0
 public void OnDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { OnDataReceived(sender, e); });
     }
     else
     {
         ParseMessage(e);
     }
 }
Пример #2
0
        private void ParseMessage(DataReceivedEventArgs e)
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(e.CommunicationMessage.Data);
            string messageType = xmlDocument.SelectSingleNode("Message/MessageType").InnerText;
            string teamId = xmlDocument.SelectSingleNode("Message/TeamId").InnerText;
            string category = xmlDocument.SelectSingleNode("Message/Category").InnerText;
            string text = xmlDocument.SelectSingleNode("Message/Text").InnerText;
            string dateTime = xmlDocument.SelectSingleNode("Message/DateTime").InnerText;

            // Ignore request for MessageList
            if (string.Equals(category, "MessageList", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // If it's a Chat Message and Blocking is on, forget it
            if (string.Equals(messageType, "Chat", StringComparison.OrdinalIgnoreCase) && _blockChatMessages)
            {
                return;
            }

            // In MasterMode we see all the messages
            if (!_masterMode)
            {
                // If teamId is filled, it's a message for a specific receiver
                if (teamId.Trim() != string.Empty)
                {
                    if (!string.Equals(teamId.Trim(), _teamId.Trim()))
                    {
                        return;
                    }
                }
            }

            UpdateGridView(messageType, category, text, dateTime);
            if (!e.CommunicationMessage.IsSynchronized())
            {
                ShowBalloon(messageType, category, text, dateTime);
                _messageInterceptor.ProcessMessage(e.CommunicationMessage.Data);
            }
        }
Пример #3
0
 void _server_DataReceived(object sender, DataReceivedEventArgs e)
 {
     e.CommunicationMessage.SetForwardFlag();
     if (e.CommunicationMessage.IsRequestForMessageList())
     {
         string teamId = e.CommunicationMessage.GetTeamId();
         SendMessageList(teamId, e.CommunicationMessage.IsMulticast);
     }
     else
     {
         AddToMessageList(e.CommunicationMessage);
         e.CommunicationMessage.IsMulticast = !e.CommunicationMessage.IsMulticast;
         _server.Enqueue(e.CommunicationMessage);
     }
 }