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); }
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 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)); }
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 }
public void PreTest() { ddna = Substitute.For <DDNABase>(null); store = Substitute.For <ActionStore>(Settings.ACTIONS_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath)); }
internal abstract bool Handle(EventTrigger trigger, ActionStore store);
public void SetUp() { store = Substitute.For <ActionStore>(Settings.ACTIONS_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath)); }
public void SetUp() { dir = Settings.ACTIONS_STORAGE_PATH.Replace( "{persistent_path}", Application.persistentDataPath); uut = new ActionStore(dir); }