Пример #1
0
 public static void LocalPlayerFriendsComplete(string json)
 {
     if (RequestFriendIdsCompleted != null)
     {
         RequestFriendIdsCompleted(AGSRequestFriendIdsResponse.FromJSON(json));
     }
 }
 public static AGSRequestFriendIdsResponse GetBlankResponseWithError(string error, int userData = 0)
 {
     AGSRequestFriendIdsResponse response = new AGSRequestFriendIdsResponse ();
     response.error = error;
     response.userData = userData;
     response.friendIds = new List<string> ();
     return response;
 }
    public static AGSRequestFriendIdsResponse GetBlankResponseWithError(string error, int userData = 0)
    {
        AGSRequestFriendIdsResponse response = new AGSRequestFriendIdsResponse();

        response.error     = error;
        response.userData  = userData;
        response.friendIds = new List <string> ();
        return(response);
    }
Пример #4
0
    /// <summary>
    /// ANDROID ONLY
    /// Requests the local player friend identifiers.
    /// </summary>
    /// <remarks>
    /// RequestFriendIdsCompleted will be called if the event is registered.
    /// </remarks>
    /// <param name="userData">
    /// An optional code that will be returned in the response. Used to associate a function call to its response.
    /// A value of 0 is not recommended because 0 is the value returned when userData is not specified.
    /// </param>
    public static void RequestFriendIds(int userData = 0)
    {
#if UNITY_EDITOR && UNITY_ANDROID
        // GameCircle only functions on device.
#elif UNITY_ANDROID
        JavaObject.Call("requestLocalPlayerFriends", userData);
#else
        if (RequestFriendIdsCompleted != null)
        {
            RequestFriendIdsCompleted(AGSRequestFriendIdsResponse.GetPlatformNotSupportedResponse(userData));
        }
#endif
    }
Пример #5
0
 private void OnRequestFriendIdsCompleted(AGSRequestFriendIdsResponse response)
 {
     if (response.IsError())
     {
         Action <bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null;
         if (callback != null)
         {
             callback(false);
         }
         simpleCallbacks.Remove(response.userData);
     }
     else
     {
         AGSPlayerClient.RequestBatchFriends(response.friendIds, response.userData);
     }
 }
 public static AGSRequestFriendIdsResponse FromJSON(string json)
 {
     try {
         AGSRequestFriendIdsResponse response = new AGSRequestFriendIdsResponse ();
         Hashtable hashtable = json.hashtableFromJson();
         response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString () : "";
         response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString ()) : 0;
         response.friendIds = new List<string> ();
         if (hashtable.ContainsKey ("friendIds")) {
             foreach (string friendPlayerId in hashtable ["friendIds"] as ArrayList) {
                 response.friendIds.Add(friendPlayerId);
             }
         }
         return response;
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return GetBlankResponseWithError(JSON_PARSE_ERROR);
     }
 }
 public static AGSRequestFriendIdsResponse FromJSON(string json)
 {
     try {
         AGSRequestFriendIdsResponse response = new AGSRequestFriendIdsResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error     = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : "";
         response.userData  = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0;
         response.friendIds = new List <string> ();
         if (hashtable.ContainsKey("friendIds"))
         {
             foreach (string friendPlayerId in hashtable["friendIds"] as ArrayList)
             {
                 response.friendIds.Add(friendPlayerId);
             }
         }
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
 private void OnRequestFriendsCompleted(AGSRequestFriendIdsResponse response)
 {
     if (response.IsError ()) {
         friendStatus = string.Format("Error getting friends: {0}", response.error);
     } else {
         if (response.friendIds.Count > 0) {
             friendIds = response.friendIds;
             friendStatus = null;
         } else {
             friendStatus = "Local player has no friends.";
         }
     }
 }
Пример #9
0
 private void OnRequestFriendIdsCompleted(AGSRequestFriendIdsResponse response)
 {
     if (response.IsError()) {
         Action<bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null;
         if (callback != null) {
             callback(false);
         }
         simpleCallbacks.Remove(response.userData);
     } else {
         AGSPlayerClient.RequestBatchFriends(response.friendIds, response.userData);
     }
 }
 private void OnGetFriendIdsCompleted(AGSRequestFriendIdsResponse response)
 {
     if (response.IsError ()) {
         friendIds = null;
         friendsRequestError = response.error;
     } else {
         friendsRequestError = "";
         friendIds = response.friendIds;
     }
 }