Exemple #1
0
 public static void AddEvent(string name, PubSubEventHandler <T> handler)
 {
     if (!events.ContainsKey(name))
     {
         events.Add(name, handler);
     }
 }
Exemple #2
0
 public static void RegisterEvent(string name, PubSubEventHandler <T> handler)
 {
     if (events.ContainsKey(name))
     {
         events[name] += handler;
     }
 }
Exemple #3
0
 public static void Subscribe(string eventName, PubSubEventHandler <T> handler)
 {
     if (events.ContainsKey(eventName))
     {
         events[eventName] += handler;
     }
 }
Exemple #4
0
 public static void PublishEvent(string eventName, PubSubEventHandler <T> handler)
 {
     if (!events.ContainsKey(eventName))
     {
         events.Add(eventName, handler);
     }
 }
Exemple #5
0
        /// <summary>
        /// Subscribe to the given topic with a handler function.
        /// </summary>
        /// <param name="topic">pub-sub topic</param>
        public void Subscribe <T>(PubSubEventHandler <T> handler) where T : PubSubEvent
        {
            string topic = PubSubEvent.GetTopicForEventType(typeof(T));

            MessageHandlers.Add(topic, new MessageHandler <T>(handler, this.Serializer));

            string topicString = topic.ToString();

            this.Socket.Subscribe(topicString);
        }
Exemple #6
0
        public static void RegisterEvent(string name, PubSubEventHandler <T> handler)
        {
            PubSubEventHandler <T> h;

            if (events.TryGetValue(name, out h))
            {
                h += handler;
            }
            else
            {
                events.Add(name, handler);
            }
        }
Exemple #7
0
 public static void AddEvent(string name, PubSubEventHandler <T> handler)
 {
     events.Add(name, handler);
 }