Beispiel #1
0
        private bool onItemsByRecent(CatalogServiceProxyEvents.OnCatalogItemsByRecent evt)
        {
            List <CatalogItemData> items         = evt.Request.Response.items;
            CatalogCacheData       cacheDataById = cache.GetCacheDataById(evt.CacheId);

            cacheDataById.Data = items;
            cache.SetCatalogCacheData(evt.CacheId, cacheDataById);
            Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.ShopItemsReponse(items));
            return(false);
        }
Beispiel #2
0
        private bool onThemesError(CatalogServiceEvents.CurrentThemesErrorEvent evt)
        {
            CatalogCacheData cacheDataById = cache.GetCacheDataById("CatalogThemeCacheId");

            if (cacheDataById.Data == null)
            {
                cacheDataById.Data = new List <CurrentThemeData>();
            }
            Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.ChallengesReponse(cacheDataById.Data as List <CurrentThemeData>));
            return(false);
        }
Beispiel #3
0
 public void GetPlayerCatalogStats()
 {
     if (cache.isShouldUseCache("catalogStatsCacheId"))
     {
         CatalogCacheData cacheDataById = cache.GetCacheDataById("catalogStatsCacheId");
         Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.StatsReponse((CatalogStats)cacheDataById.Data));
     }
     else
     {
         Service.Get <INetworkServicesManager>().CatalogService.GetPlayerCatalogStats();
     }
 }
Beispiel #4
0
 public void GetCurrentThemes()
 {
     if (cache.isShouldUseCache("CatalogThemeCacheId"))
     {
         CatalogCacheData cacheDataById = cache.GetCacheDataById("CatalogThemeCacheId");
         Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.ChallengesReponse(cacheDataById.Data as List <CurrentThemeData>));
     }
     else
     {
         Service.Get <INetworkServicesManager>().CatalogService.GetCurrentThemes();
     }
 }
Beispiel #5
0
        public void GetCatalogItemsByRecent(long scheduledThemeChallengeId, string cursor = "")
        {
            string prefixedCacheId = CatalogItemsRequest.GetPrefixedCacheId("Recent", scheduledThemeChallengeId);

            if (cache.isShouldUseCache(prefixedCacheId))
            {
                CatalogCacheData cacheDataById = cache.GetCacheDataById(prefixedCacheId);
                Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.ShopItemsReponse(cacheDataById.Data as List <CatalogItemData>));
            }
            else
            {
                new CatalogItemsByRecentRequest(scheduledThemeChallengeId, cursor);
            }
        }
Beispiel #6
0
        private bool onStats(CatalogServiceEvents.UserStatsRetrievedEvent evt)
        {
            List <CatalogItemData> currentItems    = evt.Response.currentItems;
            CatalogItemData        mostPopularItem = evt.Response.mostPopularItem;
            long             totalItemsPurchased   = evt.Response.totalItemsPurchased;
            long             totalItemsSold        = evt.Response.totalItemsSold;
            CatalogStats     catalogStats          = new CatalogStats(mostPopularItem, currentItems, totalItemsPurchased, totalItemsSold);
            CatalogCacheData cacheDataById         = cache.GetCacheDataById("catalogStatsCacheId");

            cacheDataById.Data      = catalogStats;
            cacheDataById.CacheTime = 0;
            cache.SetCatalogCacheData("catalogStatsCacheId", cacheDataById);
            Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.StatsReponse(catalogStats));
            return(false);
        }
Beispiel #7
0
        private bool onThemes(CatalogServiceEvents.CurrentThemesRetrievedEvent evt)
        {
            themeColors.SetIndex();
            List <CurrentThemeData> themes = evt.Response.themes;

            if (themes != null && themes.Count > 0)
            {
                activeThemeScheduleId = themes[0].scheduledThemeChallengeId;
                currentThemeData      = themes[0];
            }
            CatalogCacheData cacheDataById = cache.GetCacheDataById("CatalogThemeCacheId");

            cacheDataById.Data = themes;
            cache.SetCatalogCacheData("CatalogThemeCacheId", cacheDataById);
            Service.Get <EventDispatcher>().DispatchEvent(new CatalogServiceProxyEvents.ChallengesReponse(themes));
            return(false);
        }
Beispiel #8
0
        public bool isShouldUseCache(string id)
        {
            bool result = false;

            if (cache.ContainsKey(id))
            {
                CatalogCacheData catalogCacheData = cache[id];
                if ((DateTime.Now - catalogCacheData.Time).Seconds > catalogCacheData.CacheTime)
                {
                    RemoveCacheItemById(id);
                }
                else
                {
                    MoveCacheItemToFront(id);
                    result = true;
                }
            }
            return(result);
        }
Beispiel #9
0
 public void SetCatalogCacheData(string id, CatalogCacheData data)
 {
     cache[id] = data;
 }