internal override bool Handle(EventTrigger trigger, ActionStore store) { if (trigger.GetAction() == Type()) { // copy the json to avoid modifying original var response = new JSONObject(trigger.GetResponse()); var persistedParams = store.Get(trigger); if (persistedParams != null) { response["parameters"] = persistedParams; } var image = ImageMessage.Create( ddna, new Engagement("dummy") { JSON = response }, null); if (image != null && image.IsReady()) { if (persistedParams != null) { store.Remove(trigger); } callback(image); return(true); } } return(false); }
internal override bool Handle(EventTrigger trigger, ActionStore store) { if (trigger.GetAction() == Type()) { var response = trigger.GetResponse(); var persistedParams = store.Get(trigger); if (persistedParams != null) { store.Remove(trigger); callback(persistedParams); } else if (response.ContainsKey("parameters")) { callback((JSONObject)response["parameters"]); } else { callback(new JSONObject()); } return(true); } return(false); }
public void ActionReturnsImageMessageWhenPresent() { var uut = new EventTrigger( ddna, 0, "{\"response\":{\"image\":{\"a\":1}}}".Json()); Expect(uut.GetAction(), Is.EqualTo("imageMessage")); }
public void ActionReturnsGameParametersByDefault() { var uut = new EventTrigger( ddna, 0, "{\"response\":{\"image\":{}}}".Json()); Expect(uut.GetAction(), Is.EqualTo("gameParameters")); }
internal override bool Handle(EventTrigger trigger) { if (trigger.GetAction() == Type()) { var response = trigger.GetResponse(); if (response.ContainsKey("parameters")) { callback((JSONObject)response["parameters"]); } else { callback(new JSONObject()); } return(true); } return(false); }
internal override bool Handle(EventTrigger trigger) { if (trigger.GetAction() == Type()) { var image = ImageMessage.Create( ddna, new Engagement("dummy") { JSON = trigger.GetResponse() }, null); if (image != null && image.IsReady()) { callback(image); return(true); } } return(false); }