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.

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.

Comments

  • Kaiserludi
    Options
    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 call setPublishUserID(true) on the RoomOptions that you pass to opCreateRoom() / opJoinOrCreateRoom().
  • piotrros
    Options
    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?
  • piotrros
    Options
    Also, is there a way to notify friend? For example, invite him to the room.
  • Kaiserludi
    Options
    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.
  • piotrros
    Options
    Ok, is Photon Chat completely different entity? I mean, do I have to authenticate again? Just for this :) ?
  • Kaiserludi
    Options
    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.