void OnGestureDone(IGesture a_Gesture, bool a_Error) { Dictionary <string, object> response = new Dictionary <string, object>(); response["event"] = "execute_done"; response["gestureId"] = a_Gesture.GetGestureId(); response["instanceId"] = a_Gesture.GetInstanceId(); response["error"] = a_Error; TopicClient.Instance.Publish("gesture-manager", Json.Serialize(response)); }
/// <summary> /// Remove the provided gesture from the remote self instance. /// </summary> /// <param name="a_Gesture"></param> public void RemoveGesture(IGesture a_Gesture) { string gestureKey = a_Gesture.GetGestureId() + "/" + a_Gesture.GetInstanceId(); if (m_Gestures.ContainsKey(gestureKey)) { if (a_Gesture.OnStop()) { m_Gestures.Remove(gestureKey); m_Overrides.Remove(gestureKey); Dictionary <string, object> register = new Dictionary <string, object>(); register["event"] = "remove_gesture_proxy"; register["gestureId"] = a_Gesture.GetGestureId(); register["instanceId"] = a_Gesture.GetInstanceId(); TopicClient.Instance.Publish("gesture-manager", Json.Serialize(register)); Log.Status("GestureManager", "Gesture {0} removed.", gestureKey); } } }
/// <summary> /// Register a new gesture with self. If a_bOVerride is true, then any previous gesture with the same ID /// will be replaced by this new gesture. If false, then this gesture will be added alongside any existing gestures /// with the same ID. /// </summary> /// <param name="a_Gesture"></param> /// <param name="a_bOverride"></param> public void AddGesture(IGesture a_Gesture, bool a_bOverride = true) { string gestureKey = a_Gesture.GetGestureId() + "/" + a_Gesture.GetInstanceId(); if (!m_Gestures.ContainsKey(gestureKey)) { if (a_Gesture.OnStart()) { Dictionary <string, object> register = new Dictionary <string, object>(); register["event"] = "add_gesture_proxy"; register["gestureId"] = a_Gesture.GetGestureId(); register["instanceId"] = a_Gesture.GetInstanceId(); register["override"] = a_bOverride; TopicClient.Instance.Publish("gesture-manager", Json.Serialize(register)); m_Gestures[gestureKey] = a_Gesture; m_Overrides[gestureKey] = a_bOverride; Log.Status("GestureManager", "Gesture {0} added.", gestureKey); } } }
void OnConnected() { if (m_bDisconnected) { // re-register all our gestures on reconnect. foreach (var kv in m_Gestures) { string gestureKey = kv.Key; IGesture gesture = kv.Value; Dictionary <string, object> register = new Dictionary <string, object>(); register["event"] = "add_gesture_proxy"; register["gestureId"] = gesture.GetGestureId(); register["instanceId"] = gesture.GetInstanceId(); register["override"] = m_Overrides[gestureKey]; TopicClient.Instance.Publish("gesture-manager", Json.Serialize(register)); Log.Status("GestureManager", "Gesture {0} restored.", gestureKey); } m_bDisconnected = false; } }
/// <summary> /// Checks if a given IGesture objects ia already registered. /// </summary> /// <param name="a_Gesture">The IGestue object to check.</param> /// <returns>True is returned if registered.</returns> public bool IsRegistered(IGesture a_Gesture) { return(m_Gestures.ContainsKey(a_Gesture.GetGestureId())); }