Invite a friend to a room (PlayFab, PUN+ and Unity)

Options
Hello, I am still a beginner so bare with me if I am asking very basic questions, but I couldn't find similar cases to mine and would appreciate the support of someone who went through the same issue.

I am in the process of adding a new feature in our game. I would like to give the option for the players to invite their friends to join a room.

The exact description of the feature goes like this:
Player A creates a room and invites player B to join, player B has to satisfy these conditions in order to see the invitation:
1. Is a facebook friend of player A.
2. Is online and inside the lobby.

The approach i'm following to do this is as follows:
I am using PlayFab to save players data and online status.
The first time a user logs in using Facebook, a PlayFab record for this player is created, this entry includes the list of Facebook friends and online status among other data (online status for each player is updated using OnDisconnectedFromPhoton and OnJoinedLobby callbacks)

When player A clicks the invite button inside the room, the list of his online friends is shown (get list of Facebook friends -->check PlayFab records to retrieve their online status --> show Facebook friends who are online). Then the player selects the friends who they want to invite.

This is the part I am having a difficulty with. Is there a way to send the invitation message to this player in the lobby which includes the room number and the invited userId?
For example I am thinking about sending the message to all players in the lobby and then only show it to player B (show the message if the userId included in the message == player B userId). But I am hoping there is a more efficient solution because it looks like an overkill to send a message to all players in the lobby every time an invitation is sent!

Can you think of a better approach to do this?
I am open to suggestions and would appreciate your ideas!

Comments

  • vadim
    Options
    Clients can't exchange with messages while they are connected to the lobby.
    But you can create room with custom property set to friend name and filter it on other client when room list updated.
    Note: use PhotonNetwork.FindFriends while in lobby to get statuses of your friends. Set PhotonNetwork.playerName before connect to let FindFriends work.
  • avimon
    Options
    @naz89 Can you explain me how you integrated facebook and playfab with it? Please explain in detail beacause I am a beginner?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @avimon,

    We can't explain in details.
    What we can do is answer specific questions.

    You can use Photon Chat to exchange messages (not only text/string messages but more "complex" challenges/invitations) between users w/o the technical restrictions in PUN/Photon Realtime.
    PUN/Photon Realtime can tell you if a user is online or not and whether he's joined to a room or not.
    Photon Chat can send you updates whenever your friends change their online status.
    But Photon does not persist friends lists for you or keeps track of invitations/games lists for players. That's what facebook/PlayFab should do.
  • avimon
    Options
    thanks @JohnTube for the response