/// <summary> /// Adds a new handler to the internal list of message handlers. /// </summary> /// <param name="handler">The handler to add.</param> /// <exception cref="InvalidOperationException">A handler of that type is already registered.</exception> public void AddHandler(ClientMsgHandler handler) { if (handlers.Contains(handler.GetType())) { throw new InvalidOperationException(string.Format("A handler of type \"{0}\" is already registered.", handler.GetType())); } handler.Setup(this); handlers[handler.GetType()] = handler; }
/// <summary> /// Removes a registered handler. /// </summary> /// <param name="handler">The handler to remove.</param> public void RemoveHandler(ClientMsgHandler handler) { this.RemoveHandler(handler.GetType()); }