예제 #1
0
 public static void BatchFriendsRequestComplete(string json)
 {
     if (RequestBatchFriendsCompleted != null)
     {
         RequestBatchFriendsCompleted(AGSRequestBatchFriendsResponse.FromJSON(json));
     }
 }
예제 #2
0
    /// <summary>
    /// ANDROID ONLY
    /// Requests the full player information for friends of the local player.
    /// Only friends of the local player will be included in the response.
    /// </summary>
    /// <remarks>
    /// RequestBatchFriendsCompleted will be called if the event is registered.
    /// </remarks>
    /// <param name="friendIds">Player ID's for the friends requested.</param>
    /// <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 RequestBatchFriends(List <string> friendIds, int userData = 0)
    {
#if UNITY_EDITOR && UNITY_ANDROID
        // GameCircle only functions on device.
#elif UNITY_ANDROID
        string json = MiniJSON.jsonEncode(friendIds.ToArray());
        JavaObject.Call("requestBatchFriends", json, userData);
#else
        if (RequestBatchFriendsCompleted != null)
        {
            RequestBatchFriendsCompleted(AGSRequestBatchFriendsResponse.GetPlatformNotSupportedResponse(friendIds, userData));
        }
#endif
    }
 public static AGSRequestBatchFriendsResponse GetBlankResponseWithError(string error,
                                                                        List<String> friendIdsRequested = null,
                                                                        int userData = 0)
 {
     AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse ();
     response.error = error;
     response.friends = new List<AGSPlayer> ();
     if (friendIdsRequested != null) {
         foreach (string friendId in friendIdsRequested) {
             response.friends.Add(AGSPlayer.BlankPlayerWithID(friendId));
         }
     }
     response.userData = userData;
     return response;
 }
    public static AGSRequestBatchFriendsResponse GetBlankResponseWithError(string error,
                                                                           List <String> friendIdsRequested = null,
                                                                           int userData = 0)
    {
        AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse();

        response.error   = error;
        response.friends = new List <AGSPlayer> ();
        if (friendIdsRequested != null)
        {
            foreach (string friendId in friendIdsRequested)
            {
                response.friends.Add(AGSPlayer.BlankPlayerWithID(friendId));
            }
        }
        response.userData = userData;
        return(response);
    }
예제 #5
0
    private void OnRequestBatchFriendsCompleted(AGSRequestBatchFriendsResponse response)
    {
        if (!response.IsError())
        {
            AGSSocialLocalUser.friendList = new List <AGSSocialUser>();
            foreach (AGSPlayer player in response.friends)
            {
                AGSSocialLocalUser.friendList.Add(new AGSSocialUser(player));
            }
        }
        Action <bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null;

        if (callback != null)
        {
            callback(!response.IsError());
        }
        simpleCallbacks.Remove(response.userData);
    }
 public static AGSRequestBatchFriendsResponse FromJSON(string json)
 {
     try {
         AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString () : "";
         response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString ()) : 0;
         response.friends = new List<AGSPlayer>();
         if (hashtable.ContainsKey("friends")) {
             foreach ( Hashtable playerHashtable in hashtable["friends"] as ArrayList ) {
                 response.friends.Add(AGSPlayer.fromHashtable(playerHashtable));
             }
         }
         return response;
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return GetBlankResponseWithError(JSON_PARSE_ERROR);
     }
 }
 public static AGSRequestBatchFriendsResponse FromJSON(string json)
 {
     try {
         AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error    = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : "";
         response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0;
         response.friends  = new List <AGSPlayer>();
         if (hashtable.ContainsKey("friends"))
         {
             foreach (Hashtable playerHashtable in hashtable["friends"] as ArrayList)
             {
                 response.friends.Add(AGSPlayer.fromHashtable(playerHashtable));
             }
         }
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
예제 #8
0
 private void OnRequestBatchFriendsCompleted(AGSRequestBatchFriendsResponse response)
 {
     if (!response.IsError ()) {
         AGSSocialLocalUser.friendList = new List<AGSSocialUser>();
         foreach (AGSPlayer player in response.friends) {
             AGSSocialLocalUser.friendList.Add(new AGSSocialUser(player));
         }
     }
     Action<bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null;
     if (callback != null) {
         callback(!response.IsError());
     }
     simpleCallbacks.Remove(response.userData);
 }
 private void OnBatchFriendsRequestCompleted(AGSRequestBatchFriendsResponse response)
 {
     if (response.IsError ()) {
         friendsStatus = string.Format("Error requesting friends: {0}", response.error);
     } else {
         friendsStatus = "";
         friends = response.friends;
     }
 }