public static void FireEvent(string jsonMessage)
        {
            try
            {
                logger.Debug("eventReceived");
                Dictionary <string, object> jsonDict = Json.Deserialize(jsonMessage) as Dictionary <string, object>;
                string eventId = jsonDict["eventId"] as string;
                Dictionary <string, object> response = null;

                if (jsonDict.ContainsKey("response"))
                {
                    response = jsonDict["response"] as Dictionary <string, object>;
                    Jsonable.CheckForErrors(response);
                }

                lock (eventLock)
                {
                    foreach (var delegator in eventListeners[eventId])
                    {
                        if (response != null)
                        {
                            delegator.ExecuteSuccess(response);
                        }
                        else
                        {
                            delegator.ExecuteSuccess();
                        }
                    }
                }
            }
            catch (AmazonException e)
            {
                logger.Debug("Event call threw exception: " + e.ToString());
            }
        }
        private static void callbackCaller(Dictionary <string, object> response, string callerId)
        {
            IDelegator delegator = null;

            try
            {
                Jsonable.CheckForErrors(response);

                lock (AmazonMobileAdsImpl.callbackLock)
                {
                    delegator = AmazonMobileAdsImpl.callbackDictionary[callerId];
                    AmazonMobileAdsImpl.callbackDictionary.Remove(callerId);

                    delegator.ExecuteSuccess(response);
                }
            }
            catch (AmazonException e)
            {
                lock (AmazonMobileAdsImpl.callbackLock)
                {
                    if (delegator == null)
                    {
                        delegator = AmazonMobileAdsImpl.callbackDictionary[callerId];
                    }
                    AmazonMobileAdsImpl.callbackDictionary.Remove(callerId);

                    delegator.ExecuteError(e);
                }
            }
        }
Example #3
0
 public static ShouldEnable CreateFromJson(string jsonMessage)
 {
     try
     {
         Dictionary <string, object> jsonMap = Json.Deserialize(jsonMessage) as Dictionary <string, object>;
         Jsonable.CheckForErrors(jsonMap);
         return(CreateFromDictionary(jsonMap));
     }
     catch (System.ApplicationException ex)
     {
         throw new AmazonException("Error encountered while UnJsoning", ex);
     }
 }
Example #4
0
 public override void RegisterApplication()
 {
     Start();
     Jsonable.CheckForErrors(Json.Deserialize(RegisterApplicationJson("{}")) as Dictionary <string, object>);
 }
Example #5
0
 public override void SetApplicationKey(ApplicationKey applicationKey)
 {
     Start();
     Jsonable.CheckForErrors(Json.Deserialize(SetApplicationKeyJson(applicationKey.ToJson())) as Dictionary <string, object>);
 }
Example #6
0
 public override void CloseFloatingBannerAd(Ad ad)
 {
     Start();
     Jsonable.CheckForErrors(Json.Deserialize(CloseFloatingBannerAdJson(ad.ToJson())) as Dictionary <string, object>);
 }
Example #7
0
 public override void EnableGeoLocation(ShouldEnable shouldEnable)
 {
     Start();
     Jsonable.CheckForErrors(Json.Deserialize(EnableGeoLocationJson(shouldEnable.ToJson())) as Dictionary <string, object>);
 }