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