Esempio n. 1
0
        //No parameters
        public void AddListener <T>(MessengerCallback <T> handler)
        {
            var messageType = typeof(T);

            OnListenerAdding(messageType, handler);
            EventTable[messageType] = (MessengerCallback <T>)EventTable[messageType] + handler;
        }
Esempio n. 2
0
        //No parameters
        public void RemoveListener <T>(MessengerCallback <T> handler)
        {
            var messageType = typeof(T);

            OnListenerRemoving(messageType, handler);
            EventTable[messageType] = (MessengerCallback <T>)EventTable[messageType] - handler;
            OnListenerRemoved(messageType);
        }
Esempio n. 3
0
        static public void Broadcast(string eventType, MessengerMode mode)
        {
            MessengerInternal.OnBroadcasting(eventType, mode);
            Delegate d;

            if (eventTable.TryGetValue(eventType, out d))
            {
                MessengerCallback callback = d as MessengerCallback;
                if (callback != null)
                {
                    callback();
                }
                else
                {
                    throw MessengerInternal.CreateBroadcastSignatureException(eventType);
                }
            }
        }
Esempio n. 4
0
    //Three parameters
    static public void Broadcast <T, U, V>(MessengerEventType eventType, T arg1, U arg2, V arg3)
    {
#if LOG_ALL_MESSAGES || LOG_BROADCAST_MESSAGE
        Debug.Log("MESSENGER\t" + System.DateTime.Now.ToString("hh:mm:ss.fff") + "\t\t\tInvoking \t\"" + eventType + "\"");
#endif
        OnBroadcasting(eventType);

        Delegate d;
        if (eventTable.TryGetValue(eventType, out d))
        {
            MessengerCallback <T, U, V> MessengerCallback = d as MessengerCallback <T, U, V>;

            if (MessengerCallback != null)
            {
                MessengerCallback(arg1, arg2, arg3);
            }
            else
            {
                throw CreateBroadcastSignatureException(eventType);
            }
        }
    }
Esempio n. 5
0
 //Three parameters
 static public void RemoveListener <T, U, V>(MessengerEventType eventType, MessengerCallback <T, U, V> handler)
 {
     OnListenerRemoving(eventType, handler);
     eventTable[eventType] = (MessengerCallback <T, U, V>)eventTable[eventType] - handler;
     OnListenerRemoved(eventType);
 }
Esempio n. 6
0
 //Three parameters
 static public void AddListener <T, U, V>(MessengerEventType eventType, MessengerCallback <T, U, V> handler)
 {
     OnListenerAdding(eventType, handler);
     eventTable[eventType] = (MessengerCallback <T, U, V>)eventTable[eventType] + handler;
 }
Esempio n. 7
0
 static public void AddListener(string eventType, MessengerCallback handler)
 {
     MessengerInternal.OnListenerAdding(eventType, handler);
     eventTable[eventType] = (MessengerCallback)eventTable[eventType] + handler;
 }
Esempio n. 8
0
 static public void RemoveListener(string eventType, MessengerCallback handler)
 {
     MessengerInternal.OnListenerRemoving(eventType, handler);
     eventTable[eventType] = (MessengerCallback)eventTable[eventType] - handler;
     MessengerInternal.OnListenerRemoved(eventType);
 }
Esempio n. 9
0
 static public void AddListener (string eventType, MessengerCallback handler)
 {
   MessengerInternal.OnListenerAdding (eventType, handler);
   eventTable [eventType] = (MessengerCallback)eventTable [eventType] + handler;
 }
Esempio n. 10
0
 static public void RemoveListener (string eventType, MessengerCallback handler)
 {
   MessengerInternal.OnListenerRemoving (eventType, handler);  
   eventTable [eventType] = (MessengerCallback)eventTable [eventType] - handler;
   MessengerInternal.OnListenerRemoved (eventType);
 }