question

hendra avatar image
hendra asked

Message Inbox System Using Shared Group Data

Hi, I'm currently making a messaging system with these steps.

1. For each user that's newly registered, i create a new SharedGroupData with the ID of the newly registered user.

2. I send message by updating the SharedGroupData of the receiver of the message with a data object { "SenderPlayFabId" : "Messages" } (already working / done)

3. Now i want to get all of the messages by getting my SharedGroupData (with the GetSharedGroupData Server API call). But i also need the name of the sender of this message. So i get all of the keys from my SharedGroupData (which contains all of the PlayFabId of the sender) and do a for loop, each loop i call GetPlayerCombinedInfo

It's working for now, but i know that when this user has 15+ messages, this won't work. Because of the limit from Playfab.

My question is, is there a better way to get the messages + the name and other info of the sender of the message?

Thanks

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

Unfortunately, you're attempting to make a general-purpose messaging system using a component that realistically wasn't designed for that use case. Shared Group Data was specifically designed for sharing state info for asynchronous games, using a small number of keys, for a small group of users. A high number of keys isn't supported.

We'll be providing a general-purpose messaging system directly in a future update, but for now, I would recommend storing all the data you need for the message in the key/value pair directly - trying to iterate across all players to query data from each person who messaged the user isn't scalable, as it could generate a very high number of calls per player.

7 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.

hendra avatar image hendra commented ·

"I would recommend storing all the data you need for the message in the key/value pair directly"

Sorry if i misunderstood by your statement, so i should do these?

1. User 1 Send Message with { PlayFabId_FriendInbox : Message }

2. User 1 Send another data again { PlayFabId_Name : DisplayName }

Like that?

0 Likes 0 ·
brendan avatar image brendan hendra commented ·

No, I mean your key/value pair for the message would be something like:

PlayFabId: "{name of player}, {other info you want about the player}, {actual content of the message}"

0 Likes 0 ·
hendra avatar image hendra brendan commented ·

Ahh, so the key only contains the ID, and the value contains a string of info i want to get, seperated by comma.

Then i extracted the data using split function?


And also, what's the limit for the length of the key?
I think i want to store the info about the player on the key and not the value
So it will be something like this { "PlayfabId_Name_Date" : "Messages" }

The reason is so that user1 can send multiple different messages to user2 (not overriding previous messages because of the same key)

0 Likes 0 ·
Show more comments
hendra avatar image hendra commented ·

Sorry, i mean the limit on the key (the key length, not the value)
For example i have a key "PlayFabId_Name_yy-mm-dd_hh-mm-ss

0 Likes 0 ·
brendan avatar image brendan hendra commented ·

Ah, I see - yes, it's limited to 75 characters.

1 Like 1 ·
hendra avatar image hendra brendan commented ·

Thank you for the help :D

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.