players, userId and friend list
Options
Hi, I understand the concept of implementing friend list. In my "simple" version of implementation I simply want to save friend id's to the local file and retrieve details later using opFindFriends.
I get the list of all players in the room, I can use getNumber or getName, but as for getUserID it only works for the current player. For rest, it's simply an empty string. Because of that there's no way I can add friend (save it somewhere) to later retrieve his data. For the current player opFindFriends work fine.
Why getUserID returns an empty string for other players? Why am I doing wrong? Documentation clearly states I need to provide users ids.
network->mLoadBalancingClient.getCurrentlyJoinedRoom().getPlayers();
I get the list of all players in the room, I can use getNumber or getName, but as for getUserID it only works for the current player. For rest, it's simply an empty string. Because of that there's no way I can add friend (save it somewhere) to later retrieve his data. For the current player opFindFriends work fine.
Why getUserID returns an empty string for other players? Why am I doing wrong? Documentation clearly states I need to provide users ids.
0
Comments
-
Hi @piotrros.
user IDs only get broadcasted to other clients in the same room when the publish user ID room option is set to true. Its default value is false.
You need to callsetPublishUserID(true)
on theRoomOptions
that you pass toopCreateRoom()
/opJoinOrCreateRoom()
.0 -
Thanks, it's working now. I have an additional question about FriendInfo class: how to get user name? It only provides properties to get current room and check if friend is online. Oh and also userID, but it's meaningless, because I need to save it somewhere to fetch this info in the first place. Do I have to save name as well?0
-
Also, is there a way to notify friend? For example, invite him to the room.0
-
Hi @piotrros.
Yes, you should store the user names with the user IDs that you use the fetch the friend list.
There is no support for sending messages to client, which are not inside the same room, in Photon Realtime, so you can't send other players invitations to join your room directly in Photon Realtime.
To send such invitations you have the choice between either using a third-party solution or Photon Chat.0 -
Ok, is Photon Chat completely different entity? I mean, do I have to authenticate again? Just for this ?0
-
Hi @piotrros.
Yes, Photon Chat is a different product with separate appIDs and the Chat Client API establishes a separate connection to servers which use a different architecture.
Photon Realtime and Photon Chat can both be used independently from each other (if your app only requires features from one of them), but you can also use both products in combination with each other.0