Beispiel #1
0
        private async Task <string> LoadPicturePath(AdvertisementResponse advertisement)
        {
            string localPathToAdPicture = null;

            if (smartDeviceState.IsCaching)
            {
                localPathToAdPicture = fileCache.Get(advertisement.Url);
            }

            if (localPathToAdPicture == null)
            {
                localPathToAdPicture = await cvAdsAPIClient
                                       .DownloadAdvertisementPictureAsync(advertisement.Url);

                if (smartDeviceState.IsCaching)
                {
                    fileCache.Add(advertisement.Url, localPathToAdPicture);
                }
            }

            return(localPathToAdPicture);
        }
Beispiel #2
0
        public async Task RunAsync()
        {
            Logger.StartNewSection();

            var location = await geoLocationAPIClient.RetreiveLocationAsync();

            var facesDetected = await RetreiveFacesAsync();

            if (facesDetected.Length == 0)
            {
                await SleepAsync();

                return;
            }

            var environment = GetEnvironmentData(location, facesDetected);
            AdvertisementResponse advertisement = await cvAdsAPIClient
                                                  .GetAdvertisementByEnvironmentAsync(environment, smartDeviceState.AccessToken);

            if (advertisement == null)
            {
                Logger.Log("routine", "No suitable advertisement was found", ConsoleColor.Green);
                await SleepAsync();

                return;
            }
            Logger.Log("routine", $"Advertisement was found: {advertisement.Name}", ConsoleColor.Green);

            string localPathToAdPicture = await LoadPicturePath(advertisement);

            int showDuration = configurationManager.RetreiveConfiguration(config => config.ShowDuration);

            imageDisplayer.Display(localPathToAdPicture, showDuration);
            if (!smartDeviceState.IsCaching)
            {
                File.Delete(localPathToAdPicture);
            }
        }
Beispiel #3
0
        public static void Build(JSONObject response)
        {
            ResponseEvent responseEvent = Spil.MonoInstance.gameObject.AddComponent <ResponseEvent>();

            responseEvent.eventName = response.GetField("name").str;

            if (response.HasField("type"))
            {
                responseEvent.type = response.GetField("type").str;
            }

            if (response.HasField("action"))
            {
                responseEvent.action = response.GetField("action").str;
            }

            if (response.HasField("data"))
            {
                responseEvent.data = response.GetField("data");
            }

            if (responseEvent.type != null)
            {
                switch (responseEvent.type.ToLower().Trim())
                {
                case "advertisement":
                    AdvertisementResponse.ProcessAdvertisementResponse(responseEvent);
                    break;

                case "overlay":
                    OverlayResponse.ProcessOverlayResponse(responseEvent);
                    break;

                case "gameconfig":
                    ConfigResponse.ProcessConfigResponse(responseEvent);
                    break;

                case "packages":
                    PackagesResponse.ProcessPackagesResponse(responseEvent);
                    break;

                case "notification":
                    break;

                case "gamedata":
                    GameDataResponse.ProcessGameDataResponse(responseEvent);
                    break;

                case "promotions":
                    PromotionsResponse.ProcessPromotionResponse(responseEvent);
                    break;

                case "userdata":
                    UserDataResponse.ProcessUserDataResponse(responseEvent);
                    break;

                case "playerdata":
                    PlayerDataResponse.ProcessPlayerDataResponse(responseEvent);
                    break;

                case "gamestate":
                    GameStateResponse.ProcessGameStateResponse(responseEvent);
                    break;

                case "reward":
                    RewardResponse.ProcessRewardResponse(responseEvent);
                    break;

                case "liveevent":
                    LiveEventResponse.ProcessLiveEventResponse(responseEvent);
                    break;

                case "authentication":
                    SocialLoginResponse.ProcessSocialLoginResponse(responseEvent);
                    break;
                }
            }
            GameObject.Destroy(responseEvent);
        }