Пример #1
0
 public void AddSubscriber(MessageSubscriber subscriber)
 {
     MessageType[] messageTypes = subscriber.MessageTypes;
     for (int i = 0; i < messageTypes.Length; i++)
     {
         AddSubscriberToMessage(messageTypes[i], subscriber);
     }
 }
Пример #2
0
        void Start()
        {
            MessageSubscriber subscriber = new MessageSubscriber();

            subscriber.MessageTypes = MessageTypes;
            subscriber.Handler      = this;

            MessageBus.Instance.AddSubscriber(subscriber);
        }
Пример #3
0
        void AddSubscriberToMessage(MessageType messageType,
                                    MessageSubscriber subscriber)
        {
            if (!subscriberLists.ContainsKey(messageType))
            {
                subscriberLists[messageType] = new List <MessageSubscriber>();
            }

            subscriberLists[messageType].Add(subscriber);
        }
Пример #4
0
 void SendMessageToSubscriber(Message message, MessageSubscriber subscriber)
 {
     subscriber.Handler.HandleMessage(message);
 }