/// <summary> /// Handles an <c>onInviteFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// numeric representation of <c>SocialActionType</c> /// id of given request, list of invite recipients /// and payload</param> public void onInviteFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onInviteFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); String requestId = eventJson["requestId"].str; JSONObject recipientsJson = eventJson ["invitedIds"]; List <String> recipients = new List <String>(); foreach (JSONObject recipientVal in recipientsJson.list) { //iterate "feed" keys recipients.Add(recipientVal.str); } JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); //give a reward Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON)); if (reward != null) { reward.Give(); } ProfileEvents.OnInviteFinished(provider, requestId, recipients, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onGetFeedFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// json array of feeds</param> public void onGetFeedFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject feedsJson = eventJson ["feeds"]; List <String> feeds = new List <String>(); foreach (JSONObject feedVal in feedsJson.list) { //iterate "feed" keys feeds.Add(feedVal.str); } bool hasMore = eventJson["hasMore"].b; //JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); SocialPageData <String> result = new SocialPageData <String>(); result.PageData = feeds; result.PageNumber = 0; result.HasMore = hasMore; ProfileEvents.OnGetFeedFinished(provider, result); }
/// <summary> /// Handles an <c>onGetContactsFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// JSON array of <c>UserProfile</c>s and payload</param> public void onGetContactsFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); bool hasMore = eventJson["hasMore"].b; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); JSONObject userProfilesArray = eventJson ["contacts"]; List <UserProfile> userProfiles = new List <UserProfile>(); foreach (JSONObject userProfileJson in userProfilesArray.list) { userProfiles.Add(new UserProfile(userProfileJson)); } SocialPageData <UserProfile> data = new SocialPageData <UserProfile>(); data.PageData = userProfiles; data.PageNumber = 0; data.HasMore = hasMore; ProfileEvents.OnGetContactsFinished(provider, data, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onGetScoresFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onGetScoresFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetScoresFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); Leaderboard owner = new Leaderboard(eventJson["leaderboard"]); bool hasMore = eventJson["hasMore"].b; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); JSONObject scoresArray = eventJson ["scores"]; List <Score> scores = new List <Score>(); foreach (JSONObject scoreJson in scoresArray.list) { scores.Add(new Score(scoreJson)); } SocialPageData <Score> data = new SocialPageData <Score>(); data.PageData = scores; data.PageNumber = 0; data.HasMore = hasMore; ProfileEvents.OnGetScoresFinished(new GetScoresFinishedEvent(provider, owner, data, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onGetLeaderboardsFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onGetLeaderboardsFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetLeaderboardsFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); JSONObject leaderboardsArray = eventJson ["leaderboards"]; List <Leaderboard> leaderboards = new List <Leaderboard>(); foreach (JSONObject leaderboardJson in leaderboardsArray.list) { leaderboards.Add(new Leaderboard(leaderboardJson)); } SocialPageData <Leaderboard> data = new SocialPageData <Leaderboard>(); data.PageData = leaderboards; data.PageNumber = 0; data.HasMore = false; ProfileEvents.OnGetLeaderboardsFinished(new GetLeaderboardsFinishedEvent(provider, data, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onGetFeedStarted</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onGetFeedStarted(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedStarted"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); ProfileEvents.OnGetFeedStarted(provider); }
/// <summary> /// Handles an <c>onLogoutFailed</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// and payload</param> public void onLogoutFailed(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLogoutFailed"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)(eventJson["provider"].n)); String errorMessage = eventJson["message"].str; ProfileEvents.OnLogoutFailed(provider, errorMessage); }
/// <summary> /// Handles an <c>onLogoutFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c></param> public void onLogoutFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLogoutFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)(eventJson["provider"].n)); ProfileEvents.OnLogoutFinished(provider); //ProfileEvents.OnLogoutFinished(new LogoutFinishedEvent(provider)); }
/// <summary> /// Handles an <c>onLoginStarted</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// as well as payload </param> public void onLoginStarted(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginStarted"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)(eventJson["provider"].n)); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnLoginStarted(provider, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onShowLeaderboards</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// </param> public void onShowLeaderboards(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onShowLeaderboards"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnShowLeaderboards(new ShowLeaderboardsEvent(provider, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onSubmitScoreStarted</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onSubmitScoreStarted(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSubmitScoreStarted"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); Leaderboard owner = new Leaderboard(eventJson["leaderboard"]); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnSubmitScoreStarted(new SubmitScoreStartedEvent(provider, owner, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onSocialActionCancelled</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// numeric representation of <c>SocialActionType</c> and payload</param> public void onSocialActionCancelled(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSocialActionCancelled"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); SocialActionType socialAction = SocialActionType.fromInt((int)eventJson["socialActionType"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnSocialActionCancelled(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onInviteFailed</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// numeric representation of <c>SocialActionType</c>, /// error message and payload</param> public void onInviteFailed(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onInviteFailed"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); String errorMessage = eventJson["message"].str; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnInviteFailed(provider, errorMessage, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onGetContactsStarted</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onGetContactsStarted(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsStarted"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); bool fromStart = eventJson["fromStart"].b; ProfileEvents.OnGetContactsStarted(provider, fromStart, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onLoginCancelled</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// as well as payload </param> public void onLoginCancelled(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginCancelled"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)(eventJson["provider"].n)); bool autoLogin = eventJson["autoLogin"].b; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); ProfileEvents.OnLoginCancelled(provider, autoLogin, ProfilePayload.GetUserPayload(payloadJSON)); //ProfileEvents.OnLoginCancelled (new LoginCancelledEvent(provider, autoLogin, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onGetScoresFailed</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// and payload</param> public void onGetScoresFailed(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetScoresFailed"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); Leaderboard owner = new Leaderboard(eventJson["leaderboard"]); String errorMessage = eventJson["message"].str; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); bool fromStart = eventJson["fromStart"].b; ProfileEvents.OnGetScoresFailed(new GetScoresFailedEvent(provider, owner, fromStart, errorMessage, ProfilePayload.GetUserPayload(payloadJSON))); }
/// <summary> /// Handles an <c>onGetFeedFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// json array of feeds</param> public void onGetFeedFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject feedsJson = eventJson ["feeds"]; List <String> feeds = new List <String>(); foreach (String key in feedsJson.keys) { //iterate "feed" keys feeds.Add(feedsJson[key].str); } ProfileEvents.OnGetFeedFinished(provider, feeds); }
/// <summary> /// Handles an <c>onGetContactsFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c>, /// JSON array of <c>UserProfile</c>s and payload</param> public void onGetContactsFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); JSONObject userProfilesArray = eventJson ["contacts"]; List <UserProfile> userProfiles = new List <UserProfile>(); foreach (JSONObject userProfileJson in userProfilesArray.list) { userProfiles.Add(new UserProfile(userProfileJson)); } ProfileEvents.OnGetContactsFinished(provider, userProfiles, ProfilePayload.GetUserPayload(payloadJSON)); }
/// <summary> /// Handles an <c>onSocialActionFinished</c> event /// </summary> /// <param name="message"> /// Will contain a numeric representation of <c>Provider</c> /// numeric representation of <c>SocialActionType</c> and payload</param> public void onSocialActionFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSocialActionFinished"); JSONObject eventJson = new JSONObject(message); Provider provider = Provider.fromInt((int)eventJson["provider"].n); SocialActionType socialAction = SocialActionType.fromInt((int)eventJson["socialActionType"].n); JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); //give a reward Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON)); if (reward != null) { reward.Give(); } ProfileEvents.OnSocialActionFinished(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON)); }