//No parameters public void AddListener <T>(MessengerCallback <T> handler) { var messageType = typeof(T); OnListenerAdding(messageType, handler); EventTable[messageType] = (MessengerCallback <T>)EventTable[messageType] + handler; }
//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); }
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); } } }
//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); } } }
//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); }
//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; }
static public void AddListener(string eventType, MessengerCallback handler) { MessengerInternal.OnListenerAdding(eventType, handler); eventTable[eventType] = (MessengerCallback)eventTable[eventType] + handler; }
static public void RemoveListener(string eventType, MessengerCallback handler) { MessengerInternal.OnListenerRemoving(eventType, handler); eventTable[eventType] = (MessengerCallback)eventTable[eventType] - handler; MessengerInternal.OnListenerRemoved(eventType); }
static public void AddListener (string eventType, MessengerCallback handler) { MessengerInternal.OnListenerAdding (eventType, handler); eventTable [eventType] = (MessengerCallback)eventTable [eventType] + handler; }
static public void RemoveListener (string eventType, MessengerCallback handler) { MessengerInternal.OnListenerRemoving (eventType, handler); eventTable [eventType] = (MessengerCallback)eventTable [eventType] - handler; MessengerInternal.OnListenerRemoved (eventType); }