This class implements the base requirements every message handler should inherit from.
Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes a registered handler.
 /// </summary>
 /// <param name="handler">The handler to remove.</param>
 public void RemoveHandler(ClientMsgHandler handler)
 {
     this.RemoveHandler(handler.GetType());
 }