question

cartellonegerardo avatar image
cartellonegerardo asked

How to send a lets chat request?

I'm making a chat in which players can start chat conversations with specific friends.

So far I've understood that I need to use cloud-scripts for my server side code and for clients to communicate with each other I need to have them modify data in the play-fab server. Here is the plan I have for clients to make initial contact with each other and start a shared group data.

To first initiate a conversation :

A client will call a cloud script that will have the function SetObjects with the SetObjects function I want to add the clients userId to a list in the data of the user the client is attempting to contact.

Then to receive the chat request:

clients will be calling every second a cloud script that will have the GetObjects function and check the content of the list, if the list is not empty the client will be able to go through the list and accept or refuse to start a conversation with each of the users that tried to start a conversation with the client in the list.

So i guess my question is generally speaking is the approach good and if it is how can add to a list in the data of a user.

Here is the info I saw concerning entity.SetObjects:

The info i have https://community.playfab.com/questions/50106/is-there-a-way-to-send-data-between-clients.html#:~:text=Sending%20data%20directly%20between%20clients,go%20through%20the%20server%20side.

I could use GetObjects to get the list add the current username then store the new list with SetObjects but maybe their is a more optimal approach.

also I'm always confused as to why when I search the api for a function I get information on a HTTP request version but then I see here and there snippets of code that can do the job with out a HTTP request like for example here is the SetObjects object function:

https://docs.microsoft.com/en-us/rest/api/playfab/data/object/set-objects?view=playfab-rest#entitykey

Any help will be very appreciated.

CloudScript
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

·
Gosen Gao avatar image
Gosen Gao answered

I think your work flow is fine, the only thing to mention is: The client API has a limit of 100 calls every 2 minutes. You may need to reduce the frequency of calling Cloud Script to prevent affecting the operation of other API requests. Or you can use Push Notifications to notice the player when someone wants to talk so that you don't have to call Cloud Script to check it. Also, we have Party which is a chat and data communication solution, you can have a look.

PlayFab is a service based on RESTful API, which is implemented based on HTTP requests. The API document is used to check out the API request structure. Sometimes you see code that calls our API without using HTTP requests because we encapsulate the HTTP request part.

10 |1200

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

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.