/// <summary> /// Adds a ConnectDisconnect Handler /// </summary> /// <param name="msgType">The type of message that this should be added to</param> /// <param name="del">The delegate method handling the event</param> public void On(string msgType, ConnectDisconnect del) { if (!events.ContainsKey(msgType)) { events.Add(msgType, null); } events[msgType] = (ConnectDisconnect)events[msgType] + del; }
/// <summary> /// Handles an event of a given type /// </summary> /// <param name="msgType">The message type</param> /// <param name="data">The date to be passed to the handler</param> public void Handle(string msgType, dynamic data = null) { if (events.ContainsKey(msgType)) { if (data == null) { ConnectDisconnect c = (ConnectDisconnect)events[msgType]; c(); } else { MsgHandler h = (MsgHandler)events[msgType]; h(data); } } else { Logger.GetInstance().Warning("Not handling Message: " + msgType); } }
/// <summary> /// Adds a ConnectDisconnect Handler /// </summary> /// <param name="msgType">The type of message that this should be added to</param> /// <param name="del">The delegate method handling the event</param> public void On(string msgType, ConnectDisconnect del) { if (!events.ContainsKey(msgType)) events.Add(msgType, null); events[msgType] = (ConnectDisconnect)events[msgType] + del; }