The event args used by the message handler. This enables DataGram data to be passed to the handler.
Inheritance: System.EventArgs
示例#1
0
 /// <summary>
 /// 	The delegate which processes all cross AppDomain messages and writes them to screen.
 /// </summary>
 /// <param name = "sender"></param>
 /// <param name = "e"></param>
 private void OnMessageReceived(object sender, XDMessageEventArgs e)
 {
     // If called from a seperate thread, rejoin so that be can update form elements.
     if (InvokeRequired && !IsDisposed)
     {
         try
         {
             // onClosing messages may fail if the form is being disposed.
             Invoke((MethodInvoker) (() => OnMessageReceived(sender, e)));
         }
         catch (ObjectDisposedException)
         {
         }
         catch (InvalidOperationException)
         {
         }
     }
     else
     {
         switch (e.DataGram.Channel.ToLower())
         {
             case "status":
                 // pain text
                 UpdateDisplayText(e.DataGram.Channel, e.DataGram.Message);
                 break;
             default:
                 // all other channels contain serialized FormattedUserMessage object 
                 if (e.DataGram.AssemblyQualifiedName == typeof(FormattedUserMessage).AssemblyQualifiedName)
                 {
                     TypedDataGram<FormattedUserMessage> typedDataGram = e.DataGram;
                     UpdateDisplayText(typedDataGram.Channel, typedDataGram.Message.FormattedTextMessage);
                 }
                 else
                 {
                     throw new NotSupportedException(string.Format("Unknown message type: {0}", e.DataGram.AssemblyQualifiedName));
                 }
                 break;
         }
     }
 }
示例#2
0
 private void OnMessageReceived(object sender, XDMessageEventArgs e)
 {
     if (InvokeRequired && !IsDisposed)
     {
         try
         {
             Invoke((MethodInvoker) (() => OnMessageReceived(sender, e)));
         }
         catch (ObjectDisposedException)
         {
         }
         catch (InvalidOperationException)
         {
         }
     }
     else
     {
         switch (e.DataGram.Channel.ToLower())
         {
             case "status":
                 UpdateDisplayText(e.DataGram.Channel, e.DataGram.Message);
                 break;
             default:
                 if (e.DataGram.AssemblyQualifiedName == typeof (FormattedUserMessage).AssemblyQualifiedName)
                 {
                     TypedDataGram<FormattedUserMessage> typedDataGram = e.DataGram;
                     UpdateDisplayText(typedDataGram.Channel, typedDataGram.Message.FormattedTextMessage);
                 }
                 else
                 {
                     throw new NotSupportedException(string.Format("Unknown message type: {0}",
                         e.DataGram.AssemblyQualifiedName));
                 }
                 break;
         }
     }
 }
示例#3
0
        /// <summary>
        ///   Handle the MessageReceived event and trace the message to standard debug.
        /// </summary>
        /// <param name = "sender"></param>
        /// <param name = "e"></param>
        private void OnMessageReceived(object sender, XDMessageEventArgs e)
        {
            // view these debug messages using SysInternals Dbgview.
            if (e.DataGram.AssemblyQualifiedName != typeof(FormattedUserMessage).AssemblyQualifiedName)
            {
                throw new NotSupportedException(string.Format("Unknown message type: {0}",
                                                              e.DataGram.AssemblyQualifiedName));
            }
            TypedDataGram<FormattedUserMessage> dataGram = e.DataGram;

            Debug.WriteLine("Test Service: " + e.DataGram.Channel + " " + dataGram.Message);
            if (dataGram.Message.FormattedTextMessage.EndsWith("STOP"))
            {
                broadcast.SendToChannel("Status", "Stopping trace");
                isTraceEnabled = false;
            }
            else if (dataGram.Message.FormattedTextMessage.EndsWith("START"))
            {
                broadcast.SendToChannel("Status", "Starting trace");
                isTraceEnabled = true;
            }
        }