public void AddSubscriber(MessageSubscriber subscriber) { MessageType[] messageTypes = subscriber.MessageTypes; for (int i = 0; i < messageTypes.Length; i++) { AddSubscriberToMessage(messageTypes[i], subscriber); } }
void Start() { MessageSubscriber subscriber = new MessageSubscriber(); subscriber.MessageTypes = MessageTypes; subscriber.Handler = this; MessageBus.Instance.AddSubscriber(subscriber); }
void AddSubscriberToMessage(MessageType messageType, MessageSubscriber subscriber) { if (!subscriberLists.ContainsKey(messageType)) { subscriberLists[messageType] = new List <MessageSubscriber>(); } subscriberLists[messageType].Add(subscriber); }
void SendMessageToSubscriber(Message message, MessageSubscriber subscriber) { subscriber.Handler.HandleMessage(message); }