Example #1
0
 public static void AddEvent(string name, PubSubEventHandler <T> handler)
 {
     if (!events.ContainsKey(name))
     {
         events.Add(name, handler);
     }
 }
Example #2
0
 public static void RegisterEvent(string name, PubSubEventHandler <T> handler)
 {
     if (events.ContainsKey(name))
     {
         events[name] += handler;
     }
 }
Example #3
0
 public static void Subscribe(string eventName, PubSubEventHandler <T> handler)
 {
     if (events.ContainsKey(eventName))
     {
         events[eventName] += handler;
     }
 }
Example #4
0
 public static void PublishEvent(string eventName, PubSubEventHandler <T> handler)
 {
     if (!events.ContainsKey(eventName))
     {
         events.Add(eventName, handler);
     }
 }
Example #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);
        }
Example #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);
            }
        }
Example #7
0
 public static void AddEvent(string name, PubSubEventHandler <T> handler)
 {
     events.Add(name, handler);
 }