示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        public void ActionReturnsImageMessageWhenPresent()
        {
            var uut = new EventTrigger(
                ddna,
                0,
                "{\"response\":{\"image\":{\"a\":1}}}".Json());

            Expect(uut.GetAction(), Is.EqualTo("imageMessage"));
        }
示例#4
0
        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);
        }