Exemple #1
0
        private bool HandleMessage(QdmsMessage message)
        {
            //if we have any receivers, fire them
            bool handledMessage = false;

            if (ReceiveActions.Count > 0)
            {
                foreach (var action in ReceiveActions)
                {
                    if (action != null)
                    {
                        try
                        {
                            action(message);
                            handledMessage = true;
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                        }
                    }
                }
            }

            return(handledMessage);
        }
Exemple #2
0
 /// <summary>
 /// Push a message to the message bus.
 /// </summary>
 public void PushToBus(QdmsMessage msg)
 {
     if (msg.Sender == null)
     {
         msg.Sender = this;
     }
     QdmsMessageBus.Instance.PushBroadcast(msg);
 }
Exemple #3
0
        /// <summary>
        /// Receive a message.
        /// </summary>
        /// <remarks>Interface implementation.</remarks>
        public void ReceiveMessage(QdmsMessage msg)
        {
            bool handledMessage = HandleMessage(msg);

            if (!handledMessage || KeepMessagesInQueue)
            {
                MessageQueue.Enqueue(msg);
            }
        }
Exemple #4
0
 internal void PushBroadcast(QdmsMessage msg) //internal doesn't work the way I thought it did, gah
 {
     foreach (QdmsMessageInterface r in Receivers)
     {
         try
         {
             r.MessageQueue.Enqueue(msg);
         }
         catch (Exception e) //steamroll errors
         {
             Debug.Log(e);
         }
     }
 }
Exemple #5
0
        public void PushBroadcast(QdmsMessage msg, object sender)
        {
            msg.Sender = sender;

            foreach (IQdmsMessageReceiver r in Receivers)
            {
                if (r != null && r.IsValid)
                {
                    try
                    {
                        r.ReceiveMessage(msg);
                    }
                    catch (Exception e) //steamroll errors
                    {
                        Debug.Log(e);
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Receive a message.
        /// </summary>
        /// <remarks>Interface implementation.</remarks>
        public void ReceiveMessage(QdmsMessage msg)
        {
            MessageQueue.Enqueue(msg);

            HandleMessage();
        }
Exemple #7
0
 public void PushBroadcast(QdmsMessage msg)
 {
     PushBroadcast(msg, null);
 }
Exemple #8
0
 public void PushToBus(QdmsMessage msg)
 {
     msg.SetSender(this);
     QdmsMessageBus.Instance.PushBroadcast(msg);
 }
 private void HandleMessage(QdmsMessage message)
 {
     MessageEvent.Invoke(message);
 }