예제 #1
0
 public void Handle_EventTypeA(EventTypeA message, IDictionary<string, string> headers)
 {
     _log.Debug("Recieved an event of Type A with headers: " + headers.Flatten());
     try
     {
         this.Log(
             string.Format("Received an event of type A, message: {0}{1}\t{2}",
                 message.Message,
                 Environment.NewLine,
                 headers.Flatten()
             )
         );
     }
     catch (Exception ex)
     {
         this.Log(ex.ToString());
     }
 }
예제 #2
0
        private void _publishBtn_Click(object sender, EventArgs e)
        {
            string eventType = _eventTypeCbo.Text;
            if (string.IsNullOrEmpty(eventType))
            {
                this.InformUser("You must select the type of event to publish before attempting to publish an event");
                return;
            }

            string message = _eventTxt.Text;
            if (string.IsNullOrEmpty(message))
            {
                this.InformUser("You should add a message to the event before publishing it");
                return;
            }

            object eventMsg = null;

            switch (eventType)
            {
                case "amp.examples.gui.messages.EventTypeA":
                    eventMsg = new EventTypeA() { Message = message };
                    break;
                case "amp.examples.gui.messages.EventTypeB":
                    eventMsg = new EventTypeB() { Message = message };
                    break;
                default:
                    this.WarnUser("I don't know how to send the type of event you selected.  This should not have happened.");
                    break;
            }

            try
            {
                this.EventBus.Publish(eventMsg);
            }
            catch (Exception ex)
            {
                this.Log(ex.ToString());
            }
        }