Photon Friends list while connected to Room

Hi Photon,

I am using below pasted code to get my friends status from photon i.e if they are online and in lobby or in some room. Everything works as expected if "FindFriends" calling peer is not connected to any room and is currently only in lobby.



Code:
void findOnlineFriends()
	{
		string[] _friendList = PlayerDataManager.instance.friendsList.ToArray ();
		PhotonNetwork.FindFriends (_friendList);
	}

public void OnUpdatedFriendList()
	{
		Debug.Log("Updated: " + PhotonNetwork.Friends.Count.ToString());
		if (onListUpdated != null) {
			onListUpdated ();
		}
	}
Errors:
1. Operation failed: OperationResponse 222: ReturnCode: -2 (Unknown operation code). Parameters: {} Server: GameServer
UnityEngine.Debug:LogError(Object)
2. FindFriends failed to apply the result, as a required value wasn't provided or the friend list length differed from result.
UnityEngine.Debug:LogError(Object)

Comments

  • N1warhead
    N1warhead ✭✭
    edited August 2017
    Which of them lines specifically are giving the error?
    From my reading of your post both errors are resulting from the second error. It's missing some sort of value to indicate what to do or the length of the friendlist isn't equaled to the real value of it.

    So to me, it's looking like it's 'string[] _friendList' is where your problem is at. Just make sure, at the time you are calling this method that the PlayerDataManager is populated. (I've never used the friendlist stuff yet), but something tells me you should be doing something like 'PlayerDataManager dataManager;' sometimes calling a class directly like you're doing isn't good and would rather need a reference too it.

    If you are calling this PlayerDataManager like that, make sure it's a static and the friendlist data is also a static.

    This is all just ideas, I haven't used friendlist yet, but I hope I at least gave you some helpful information that may help ya out.

    Take care,
    David.


    EDIT----
    Sorry I believe I read what your problem was the wrong way, I'm super tired. been coding for 16 hours straight.... If this sounds like complete non-sense, I am sorry... I didn't see a way to delete my answer.
  • I have exposed my list in inspector and list does have correct values, same code works fine if I am not connected to some room.

    My dataManagers and other implementations are fine, I doubt Photon limits access to friends list only if you are in lobby.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @alihcme,

    Thank you for choosing Photon!

    I doubt Photon limits access to friends list only if you are in lobby.
    A Photon client can get friends list only when connected to a Master Server, i.e. not joined to a room.