コード例 #1
0
ファイル: MocsForm.cs プロジェクト: ruudkok/MoCS
 public void OnDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { OnDataReceived(sender, e); });
     }
     else
     {
         ParseMessage(e);
     }
 }
コード例 #2
0
ファイル: MocsForm.cs プロジェクト: ruudkok/MoCS
        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
ファイル: Notify.cs プロジェクト: ruudkok/MoCS
 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);
     }
 }