public bool ValidatePayload(EventPayload payload) { if (payload == null) { return(true); } return(CheckContentAs(payload.ContentType, payload.GetContent())); }
public void TriggerEvent(EventKey eventKey, EventPayload payload) { if (EventPayloadLibrary != null) { if (eventKey == EventKey.None) { throw new ArgumentException("Cannot trigger a null event!"); } if (!EventPayloadLibrary.ValidatePayload(payload)) { throw new ArgumentException("Invalid payload!"); } } FlushListeners(); TofuEvent evnt = GetEvent(eventKey); if (!_eventListeners.ContainsKey(evnt) || _eventListeners[evnt].Count == 0) { return; } _events.Get(evnt.Key).HasBeenCalled(); List <IListener> listeners = new List <IListener>(_eventListeners[evnt]); foreach (IListener listener in listeners) { listener.ReceiveEvent(evnt, payload); } if (EventLogger != null) { if (payload == null) { EventLogger.LogEvent(Time.time, eventKey, "NULL"); } else { EventLogger.LogEvent(Time.time, eventKey, payload.ContentType); } } }