Transporting PlayFab friends to Photon
Can anyone guide me how can I transport my friendslist from PlayFab to Photon? I have got authentication successfully done as it is given in the docs. I am using Photon Unity Networking. Is it necessary to join a room before getting friends list or friends list can be retrieved if only connected to master server also?
0
Comments
-
Hi @avimon,
Why do you need to move your PlayFab's friends list from PlayFab to Photon?
Photon's FindFriends feature works outside of rooms, it informs you if users are connected or not and if connected if they are in a room or not and if they are in a room which one.0 -
1- get the list of friends from PlayFab using one of their client API methods
2- get the PlayFabIds from that list into a string array (string[]
)
3- callPhotonNetwork.FindFriends
using the at array of UserIDs from 2
4- wait for the callbackvoid OnUpdatedFriendList()
1 -
@JohnTube
I am using this code :private void OnConnectedToMaster() { GetFriends(); } public void GetFriends() { PlayFabClientAPI.GetFriendsList( new GetFriendsListRequest() { ProfileConstraints = null }, FriendListResult, OnPlayFabError); } private void FriendListResult(GetFriendsListResult result) { for (int i = transform.childCount - 1; i >= 0; i--) { Destroy(transform.GetChild(i).gameObject); } string[] friendsToFind = null; FriendInfo = result.Friends; for (int i = 0; i < result.Friends.Count; i++) { PlayFab.ClientModels.FriendInfo friendInfo = result.Friends.ElementAt(i); friendsToFind[i] = friendInfo.FriendPlayFabId; } PhotonNetwork.FindFriends(friendsToFind); } private void OnUpdatedFriendList() { Debug.Log(PhotonNetwork.Friends.Count); }
but I am getting errors. What am I doing wrong?0 -
What errors? Can you share the error message and stacktrace?
You need to create the array first:
instead of:string[] friendsToFind = null;
do:string[] friendsToFind = new string[result.Friends.Count];
And I think this is wrong:FriendInfo = result.Friends;
and I would change this:PlayFab.ClientModels.FriendInfo friendInfo = result.Friends.ElementAt(i);
to:PlayFab.ClientModels.FriendInfo friendInfo = result.Friends[i];
1