Пример #1
0
        public void SubscribeToType(string a_Type, OnThingEvent a_Callback, ThingEventType a_EventMask = ThingEventType.TE_ALL, string a_Path = "")
        {
            if (!m_SubscriberMap.ContainsKey(a_Path))
            {
                TopicClient.Instance.Subscribe(a_Path + "blackboard", OnBlackBoardEvent);
                m_SubscriberMap[a_Path] = new Dictionary <string, List <Subscriber> >();
            }

            Dictionary <string, List <Subscriber> > types = m_SubscriberMap[a_Path];

            if (!types.ContainsKey(a_Type))
            {
                types[a_Type] = new List <Subscriber>();

                Dictionary <string, object> subscribe = new Dictionary <string, object>();
                subscribe["event"]      = "subscribe_to_type";
                subscribe["type"]       = a_Type;
                subscribe["event_mask"] = (int)ThingEventType.TE_ALL;       // we want all events, we will filter those events on this side

                TopicClient.Instance.Publish(a_Path + "blackboard", Json.Serialize(subscribe));
            }

            types[a_Type].Add(new Subscriber(a_Callback, a_EventMask, a_Path));
        }
Пример #2
0
 /// <summary>
 /// Gets the name for an Actium event with a unique GameObject ID.
 /// </summary>
 /// <returns>The Actium event name.</returns>
 /// <param name="eventType">Event type.</param>
 public string GetActiumEventNameWithID(ThingEventType eventType)
 {
     return GetActiumEventNameWithID(eventType.ToString());
 }
Пример #3
0
 public void Dispatch(ThingEventType eventType, object sender = null)
 {
     Dispatch(GetActiumEventNameWithID(eventType), sender);
 }
Пример #4
0
    /// <summary>
    /// Set up an event listener in Actium relevant to ThingEventType of the contributor thing, adds contributor's GameObject ED to the event name.
    /// </summary>
    /// <param name="contributor">Contributor.</param>
    /// <param name="eventType">Event type.</param>
    /// <param name="handler">Handler.</param>
    public void On(Thing contributor, ThingEventType eventType, ActiumEventHandler handler)
    {
        var eventName = contributor.GetActiumEventNameWithID(eventType);

        contributor.On(eventName, handler);
    }
Пример #5
0
    /// <summary>
    /// Set up an event listener in Actium relevant to ThingEventType, adds a GameObject ID to the event name.
    /// </summary>
    /// <param name="eventType">Event type.</param>
    /// <param name="handler">Event handler.</param>
    public void On(ThingEventType eventType, ActiumEventHandler handler)
    {
        var eventName = GetActiumEventNameWithID(eventType);

        On(eventName, handler);
    }
Пример #6
0
 public Subscriber(OnThingEvent a_Callback, ThingEventType a_EventMask, string a_Path)
 {
     m_Callback  = a_Callback;
     m_EventMask = a_EventMask;
     m_Path      = a_Path;
 }
Пример #7
0
    /// <summary>
    /// Set up an event listener in Actium relevant to ThingEventType, adds a GameObject ID to the event name.
    /// </summary>
    /// <param name="eventType">Event type.</param>
    /// <param name="handler">Event handler.</param>
    public void On(ThingEventType eventType, ActiumEventHandler handler)
    {
        var eventName = GetActiumEventNameWithID(eventType);

        On(eventName, handler);
    }
Пример #8
0
 /// <summary>
 /// Gets the name for an Actium event with a unique GameObject ID.
 /// </summary>
 /// <returns>The Actium event name.</returns>
 /// <param name="eventType">Event type.</param>
 public string GetActiumEventNameWithID(ThingEventType eventType)
 {
     return(GetActiumEventNameWithID(eventType.ToString()));
 }
Пример #9
0
 public void Dispatch(ThingEventType eventType, object sender = null)
 {
     Dispatch(GetActiumEventNameWithID(eventType), sender);
 }
Пример #10
0
    /// <summary>
    /// Set up an event listener in Actium relevant to ThingEventType of the contributor thing, adds contributor's GameObject ED to the event name.
    /// </summary>
    /// <param name="contributor">Contributor.</param>
    /// <param name="eventType">Event type.</param>
    /// <param name="handler">Handler.</param>
    public void On(Thing contributor, ThingEventType eventType, ActiumEventHandler handler)
    {
        var eventName = contributor.GetActiumEventNameWithID(eventType);

        contributor.On(eventName, handler);
    }