Example #1
0
        static void AddSendLogEntry(BaseMessage msg, string message)
        {
#if UNITY_EDITOR
            if (!msg.DontShowInEditorLogInternal)
            {
                MessageLogHandler.AddLogEntry(LogEntryType.Send, msg.Name, msg.ToString(), message);
            }
#endif
        }
Example #2
0
        /// <summary>
        /// Add the specified message to the processing queue for sending.
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool QueueMessage(BaseMessage msg)
        {
            // if no listeners then just return.
            if (!_listeners.ContainsKey(msg.Name))
            {
                MessageLogHandler.AddLogEntry(LogEntryType.Send, msg.Name, msg.ToString(), "No listeners are setup. Discarding message!");
                return(false);
            }

            _messageQueue.Enqueue(msg);
            return(true);
        }
Example #3
0
        /// <summary>
        /// Immediately send the specified message to all listeners.
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool TriggerMessage(BaseMessage msg)
        {
            if (!_listeners.ContainsKey(msg.Name))
            {
                MessageLogHandler.AddLogEntry(LogEntryType.Send, msg.Name, msg.ToString(), "No listeners are setup. Discarding message!");
                return(false);
            }

            List <MessageListenerDelegate> listenerList = _listeners[msg.Name];

            for (int i = 0; i < listenerList.Count; ++i)
            {
                var sent = listenerList[i](msg);

                if (msg.SendMode == BaseMessage.SendModeType.SendToFirst && sent)
                {
                    MessageLogHandler.AddLogEntry(LogEntryType.Send, msg.Name, msg.ToString(), "Sent to first listener.");
                    return(true);
                }
            }
            MessageLogHandler.AddLogEntry(LogEntryType.Send, msg.Name, msg.ToString(), "Sent to " + listenerList.Count + " listeners.");
            return(true);
        }