/// <summary> /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are /// refreshed (prices, titles ...). /// </summary> /// <param name="message">Message that contains information about the process that is occurring.</param> public void onMarketItemsRefreshFinished(string message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message); string[] marketItemsChanges = Regex.Split(message, "#SOOM#"); List <MarketItem> marketItems = new List <MarketItem>(); foreach (string mic in marketItemsChanges) { if (string.IsNullOrEmpty(mic.Trim())) { continue; } JSONObject micJSON = new JSONObject(mic); string productId = micJSON["productId"].str; string marketPrice = micJSON["market_price"].str; string marketTitle = micJSON["market_title"].str; string marketDescription = micJSON["market_desc"].str; try { PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId); MarketItem mi = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem; mi.MarketPrice = marketPrice; mi.MarketTitle = marketTitle; mi.MarketDescription = marketDescription; pvi.save(); marketItems.Add(mi); } catch (VirtualItemNotFoundException ex) { SoomlaUtils.LogDebug(TAG, ex.Message); } } StoreEvents.OnMarketItemsRefreshFinished(marketItems); }
/// <summary> /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are /// refreshed (prices, titles ...). /// </summary> /// <param name="message">Message that contains information about the process that is occurring.</param> public void onMarketItemsRefreshFinished(string message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message); string[] marketItemsChanges = Regex.Split(message, "#SOOM#"); List <MarketItem> marketItems = new List <MarketItem>(); foreach (string mic in marketItemsChanges) { if (string.IsNullOrEmpty(mic.Trim())) { continue; } JSONObject micJSON = new JSONObject(mic); string productId = micJSON[JSONConsts.MARKETITEM_PRODUCT_ID].str; string marketPrice = micJSON[JSONConsts.MARKETITEM_MARKETPRICE].str; string marketTitle = micJSON[JSONConsts.MARKETITEM_MARKETTITLE].str; string marketDescription = micJSON[JSONConsts.MARKETITEM_MARKETDESC].str; string marketCurrencyCode = micJSON[JSONConsts.MARKETITEM_MARKETCURRENCYCODE].str; long marketPriceMicros = System.Convert.ToInt64(micJSON[JSONConsts.MARKETITEM_MARKETPRICEMICROS].n); try { PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId); MarketItem mi = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem; mi.MarketPriceAndCurrency = marketPrice; mi.MarketTitle = marketTitle; mi.MarketDescription = marketDescription; mi.MarketCurrencyCode = marketCurrencyCode; mi.MarketPriceMicros = marketPriceMicros; pvi.save(); marketItems.Add(mi); } catch (VirtualItemNotFoundException ex) { SoomlaUtils.LogDebug(TAG, ex.Message); } } StoreEvents.OnMarketItemsRefreshFinished(marketItems); }