Example #1
0
 /// <summary>
 /// Registers a temporary handler for the given message type.
 /// </summary>
 public Binding RegisterTemp(MsgType inType, MsgActionHandler inHandler)
 {
     if (m_Impl.IsValid)
     {
         return(new Binding(this, inType, (m) => inHandler()));
     }
     return(null);
 }
Example #2
0
 /// <summary>
 /// Deregisters a handler for the given message type.
 /// </summary>
 public Messenger Deregister(MsgType inType, MsgActionHandler inHandler)
 {
     if (m_Impl.IsValid)
     {
         m_Impl.Deregister(inType, inHandler);
     }
     return(this);
 }
Example #3
0
        public void Register(MsgActionHandler inAction)
        {
            if (m_DebugMode && m_Metadata.CanLog(LogFlags.Register))
            {
                m_Manager.Log(m_Owner.Owner.name + " registered listener for " + m_Metadata.Name);
            }

            m_Actions += inAction;
        }
Example #4
0
 /// <summary>
 /// Registers a handler for the given message type.
 /// </summary>
 public MsgTable Batch(MsgType inType, MsgActionHandler inHandler)
 {
     if (m_Entries == null)
     {
         m_Entries = new List <IEntry>();
     }
     m_Entries.Add(new ActionHandlerEntry(inType, inHandler));
     return(this);
 }
Example #5
0
        public void Dispose()
        {
            m_Owner     = null;
            m_Manager   = null;
            m_DebugMode = false;

            m_Metadata       = null;
            m_AllowedArgType = null;
            m_Handlers       = null;
            m_Actions        = null;
            if (m_Typed != null)
            {
                m_Typed.Dispose();
                m_Typed = null;
            }
        }
Example #6
0
        /// <summary>
        /// Deregisters a handler for the given MsgType.
        /// </summary>
        public void Deregister(MsgType inType, MsgActionHandler inHandler)
        {
            ValidateRegisterArgs(inType, inHandler);

            DelegateBlock handler;

            if (m_Handlers.TryGetValue(inType, out handler))
            {
                handler.Deregister(inHandler);
                if (handler.IsEmpty())
                {
                    handler.Dispose();
                    m_Handlers.Remove(inType);
                    if (m_Parent != null)
                    {
                        m_Parent.Deregister(inType, this);
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// Registers a handler for the given MsgType.
        /// </summary>
        public void Register(MsgType inType, MsgActionHandler inHandler)
        {
            ValidateRegisterArgs(inType, inHandler);

            DelegateBlock handler;

            if (m_Handlers.TryGetValue(inType, out handler))
            {
                handler.Register(inHandler);
            }
            else
            {
                handler = m_Handlers[inType] = new DelegateBlock(this, m_Manager, inType);
                handler.Register(inHandler);
                if (m_Parent != null)
                {
                    m_Parent.Register(inType, this);
                }
            }
        }
Example #8
0
 public ActionHandlerEntry(MsgType inType, MsgActionHandler inHandler)
 {
     Type    = inType;
     Handler = inHandler;
 }