Exemplo n.º 1
0
        public void AddSubscriber(MessageSubscriber subscriber)
        {
            string[] messageTypes = subscriber.MessageTypes;
            for (int i = 0; i < messageTypes.Length; i++)
            {
                AddSubscriberToMessage(messageTypes[i], subscriber);
            }

            //UnityEngine.Debug.Log("AddSubscriber: " + subscriber.MessageTypes.ToString());
            //UnityEngine.Debug.Log("queue.Count: " + queue.Count.ToString());

            for (int i = 0; i < queue.Count; i++)
            {
                bool finded = false;
                foreach (string type in subscriber.MessageTypes)
                {
                    if (queue[i].Type == type)
                    {
                        subscriber.action(queue[i]);


                        finded = true;
                        break;
                    }
                }

                //if(finded)
                //{
                //    queue.Remove(queue[i]);
                //}
            }
        }
Exemplo n.º 2
0
        void SendMessageToSubscriber(Message message,
                                     MessageSubscriber subscriber)
        {
            if (disposable_subscibers.ContainsKey(message.Type))
            {
                foreach (var m in disposable_subscibers[message.Type])
                {
                    SendMessage(m);
                }

                disposable_subscibers[message.Type].Clear();
            }
            //UnityEngine.Debug.Log(message.Type);
            subscriber.action(message);
        }