question

Reid Taylor avatar image
Reid Taylor asked

Friends and chat

Hello, we are working on a mobile multiplayer game. We use PlayFab for accounts and save data, Photon for rooms and general networking gameplay, and Unity as our game engine. In our game it is very important to have friends. I have worked tirelessly on this issue... First we needed friend request so I figured out this (very difficult) system for request confirmation. At the end this was no help what so ever because we need more... We want to be able to send friend request and the requested player instantly (obvious delay) receives the request and can accept it. Then once friends, they should be able to chat, invite to a team party, etc... This all is surrounded by a specific problem. PlayFab allows no way (that I or any help I've been given know of) to send data to a player that receives a callback when they receive it. I have tried using cloud script and have found no way. Please help or give any useful information you have. Thanks!

Player DatadataFriends
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

·
Seth Du avatar image
Seth Du answered

For a private chat, we usually suggest using Shared Group Data to store logs and it can be handled by Cloud Script/Azure Function, while SendPushNotification API can be called there to inform the another player. This solution can be applied to a small group, but is not recommended when there is a large group because concurrent data writing error can occur.

A better solution is to use the new feature PlayFab Party, please refer to: Azure PlayFab Party overview - PlayFab | Microsoft Docs. In addition, since you are using Photon, using Photon chat is also feasible.

In terms of friend request, it can be done via Cloud Script/Azure function. Here is some tips:

  • Disable AddFriend client API via editing API policy
  • Implement a “SendFriendReuqest” function. Each player will have 1 KVP in Player Read-Only Data – “Sent Request” and “Received Request”.
  • When Player A call this function to send friend request for Player B. the Request log will be stored in Player A’s “Sent Request” and Player B’s “Received Request”.
  • If the request already exists in Player B’s “Sent Request”, they will be friend immediately, the request log will be removed then.
  • Player B will be able to Approve or Decline the request, which is another Cloud Script function. When approved, simply remove the log in “Sent Request” and “Received Request” of both players. While when declined, remove the request of both sides.
2 comments
10 |1200

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

Reid Taylor avatar image Reid Taylor commented ·

@SethDuThanks for your response! First of all I need to clarify that we are using the free version of PlayFab (which to my knowledge does not support PlayFab multiplayer). And about the friend requests this is exactly what I did... The problem is that it is not realtime. So when a friend request is sent there is no way to have something happen realtime on the requested players screen because there is no realtime callback feature. Am I missing something?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Reid Taylor commented ·

It is not supported due to the Restful API nature of PlayFab. As a workaround, you may send push notification when player approves or declines the request, while the client can force a refresh when the player clicks the notification. Otherwise, the client should refresh the data in a specific interval and updates the latest request list every time they open that panel.

0 Likes 0 ·

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.