brendan avatar image
brendan asked

Friends management flow

Question from a developer:

How to manage friends in the sticker challenge like game?
I want to create game like user can send message to another from their contact book and another user can revert with response to message.
I am not having PlayFab Id of the friends in my contact list.
I want to manage friends those I have played against that are in my contact book.
So please expalin me flow for it.

Shared Group DataFriends
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

brendan avatar image
brendan answered

We are planning to provide a generic message system in a future sprint, though for right now, you could implement a simple message passing model using Shared Group Data. The way you would do this is by having a Shared Group Data per player, with an ID of something like { {PlayFabID}}_Messages (where you replace { {PlayFabID}} with the player's actual ID). Then, a player sending a message to this player would create a Key/Value pair in that Shared Group Data using his own PlayFabID for the Key and the message would be the Value. The receiving player would then delete those Keys from the Shared Group Data when the messages are pulled down to the client. Note that this would necessarily be somewhat limited, as a Shared Group Data by default only provides 100 Key/Value pairs, and if a player wanted to send another message to the same player before that player has read his outstanding messages, he would need to overwrite the existing message (you could add to it, but you would likely need more than the default 1000 bytes for the Value).

As to the friends management aspect of this, I would recommend using the Friends system as designed. You would add players to the Friends list using Client/AddFriend. If you wanted to differentiate between "contacts" and "friends", you could use Client/SetFriendTags to set some custom tags on the players, to let you know which are only contacts, and which are friends.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Follow-up question from the developer:

In game First time player don't know the playfab Id of the opponent because they are only in the contact list.
I have some flow in mind as follow :
Player_1 create a game and send letter to the Player_2.
Player_2 get a letter with the Player_1 PlayFab ID and call Client/AddFriend method for received PlayFab ID. Now Player_1 is friend of Player_2 but not vice versa as per the GetFriendsList client API. When Player_2 send message to Player_1 then Player_2 will become a friend with Player_1 by following above procedure.
Is this flow is correct for manage friends?


Yes, the friends system is a "follow" type system - it is one-way. So to add someone to the friends list for any particular player, you must call AddFriend for that player.

0 Likes 0 · avatar image commented ·

Hello, Brendan, I have some additional questions.

I've implemented custom mechanism to handle invite system, i.e. some player could send invite to other one, and then second player can accept or decline it, and also he can distinguish both-side accepted friends from one-side (I used player's read only data storage to keep needed information).

But for now this scheme is a little bit complicated, and it has some limitations. I'm thinking about switching to use SetFriendTags instead (mark player that it's already accepted as friend). The problem is that SetFriendTags is client side only, so I can't call this method on server side (something like this - player1 accepts invite by calling AddFriend with ID of player2, then calls on server side SetFriendTags for player2, and sets tag for player1, so both of them could know that they are two-sided friends now).

So, is it possible to use somehow SetFriendTags on server side, or may be you have plans to expand server side API (I know that some friends related API calls were added recently). Or may be friends management flow will be expanded later to support two-sided friends.

Any recommendations about this will be very helpful, thanks.

0 Likes 0 ·
brendan avatar image brendan commented ·

Yes, we'll be expanding the Server API set to include more of the Client API calls soon.

0 Likes 0 · avatar image brendan commented ·

Thanks for quick answer, but could you say approximately, how soon it will be. One month, less or more, or may be it will take much longer time.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.