Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        internal DDNAImpl(DDNA ddna) : base(ddna)
        {
            string eventStorePath = null;

            if (Settings.UseEventStore)
            {
                eventStorePath = Settings.EVENT_STORAGE_PATH
                                 .Replace("{persistent_path}", Application.persistentDataPath);
                if (!Utils.IsDirectoryWritable(eventStorePath))
                {
                    Logger.LogWarning("Event store path unwritable, event caching disabled.");
                    Settings.UseEventStore = false;
                }
            }

            eventStore = new EventStore(eventStorePath);
            if (Settings.UseEventStore && !eventStore.IsInitialised)
            {
                // failed to access files for some reason
                Logger.LogWarning("Failed to access event store path, event caching disabled.");
                Settings.UseEventStore = false;
                eventStore             = new EventStore(eventStorePath);
            }
            engageCache = new EngageCache(Settings);
            actionStore = new ActionStore(Settings.ACTIONS_STORAGE_PATH
                                          .Replace("{persistent_path}", Application.persistentDataPath));
            ImageMessageStore     = new ImageMessageStore(ddna);
            executionCountManager = new ExecutionCountManager();

            EngageFactory = new EngageFactory(this);
        }
 internal EventAction(
     GameEvent evnt,
     ReadOnlyCollection <EventTrigger> triggers,
     ActionStore store)
 {
     this.evnt     = evnt;
     this.triggers = triggers;
     this.store    = store;
 }
        public void RetrievingActionAfterReinitialisation()
        {
            var trigger = Substitute.For <EventTrigger>();

            trigger.GetCampaignId().Returns(1);
            var action = new JSONObject()
            {
                { "a", 1 }
            };

            uut.Put(trigger, action);
            uut = new ActionStore(dir);

            Expect(uut.Get(trigger), Is.EqualTo(action));
        }
Exemple #6
0
        internal DDNAImpl(DDNA ddna) : base(ddna)
        {
            string eventStorePath = null;

            if (Settings.UseEventStore)
            {
                eventStorePath = Settings.EVENT_STORAGE_PATH
                                 .Replace("{persistent_path}", Application.persistentDataPath);
                if (!Utils.IsDirectoryWritable(eventStorePath))
                {
                    Logger.LogWarning("Event store path unwritable, event caching disabled.");
                    Settings.UseEventStore = false;
                }
            }

            eventStore = new EventStore(eventStorePath);
            if (Settings.UseEventStore && !eventStore.IsInitialised)
            {
                // failed to access files for some reason
                Logger.LogWarning("Failed to access event store path, event caching disabled.");
                Settings.UseEventStore = false;
                eventStore             = new EventStore(eventStorePath);
            }
            engageCache = new EngageCache(Settings);
            actionStore = new ActionStore(Settings.ACTIONS_STORAGE_PATH
                                          .Replace("{persistent_path}", Application.persistentDataPath));
            ImageMessageStore     = new ImageMessageStore(ddna);
            executionCountManager = new ExecutionCountManager();

            #if DDNA_SMARTADS
            // initialise SmartAds so it can register for events
            var smartAds = SmartAds.Instance.Config(engageCache);
            smartAds.transform.parent = gameObject.transform;

            EngageFactory = new EngageFactory(this, smartAds);

            Application.RequestAdvertisingIdentifierAsync(
                (string advertisingId, bool trackingEnabled, string error) => {
                if (trackingEnabled)
                {
                    PlayerPrefs.SetString(DDNA.PF_KEY_ADVERTISING_ID, advertisingId);
                }
            }
                );
            #else
            EngageFactory = new EngageFactory(this, null);
            #endif
        }
Exemple #7
0
 public void PreTest()
 {
     ddna  = Substitute.For <DDNABase>(null);
     store = Substitute.For <ActionStore>(Settings.ACTIONS_STORAGE_PATH
                                          .Replace("{persistent_path}", Application.persistentDataPath));
 }
Exemple #8
0
 internal abstract bool Handle(EventTrigger trigger, ActionStore store);
 public void SetUp()
 {
     store = Substitute.For <ActionStore>(Settings.ACTIONS_STORAGE_PATH
                                          .Replace("{persistent_path}", Application.persistentDataPath));
 }
Exemple #10
0
 public void SetUp()
 {
     dir = Settings.ACTIONS_STORAGE_PATH.Replace(
         "{persistent_path}", Application.persistentDataPath);
     uut = new ActionStore(dir);
 }