My goal is just to have my client change data in another users account.
It's suppose to be a notification that the client user requested to chat. Later the user that recieved the data should do a GetObjects to see if he has a chat request. This question is related a bit to the question @Gosen Gao answered : https://community.playfab.com/questions/61685/how-to-send-a-lets-chat-request.html
here is my javascript cloudscript code:
handlers.askChat = function (args, context) { entity.SetObjects({ Entity: { Id: args.ReceiverEntityId, Type: "title_player_account", TypeString: "title_player_account" }, Objects: [{ ObjectName: "ChatRequests", DataObject: {IdUserRequesting:currentPlayerId} }] }); };
I also tried this version:
handlers.askChat = function (args, context) { var headers = { "X-EntityToken": entity.GetEntityToken()//this is just a guess from what I read in the api }; var body = { Entity: {Id: args.ReceiverEntityId,Type: "title_player_account",TypeString: "title_player_account"}, Objects: [{ObjectName: "ChatRequests",DataObject: currentPlayerId}] }; var url = "https://titleId.playfabapi.com/Object/GetObjects ";//i put my correct title id var content = JSON.stringify(body); var httpMethod = "post"; var contentType = "application/json"; // The pre-defined http object makes synchronous HTTP requests var response = http.request(url, httpMethod, content, contentType, headers); return { responseContent: response }; };
i think i feel more comfortable using the code above with the HTTP request since I'm not sure I understand how the first piece of code is written based from the API:.
If there is documentation about that would appreciate to know where.
Here is my unity code : (friendInfoCon.FriendPlayFabId I checked, does indeed give me the playfab id as expected, it comes from me having used PlayFabClientAPI.GetFriendsList somewhere else in my code)
using PlayFab; using PlayFab.ClientModels; using PlayFab.CloudScriptModels; FriendInfo friendInfoCon; private void CallAskChatFunction() { var request = new ExecuteCloudScriptRequest { FunctionName = "askChat", FunctionParameter = new { ReceiverEntityId = friendInfoCon.FriendPlayFabId }, GeneratePlayStreamEvent = true }; PlayFabClientAPI.ExecuteCloudScript(request, (PlayFab.ClientModels.ExecuteCloudScriptResult result) => { if(result!=null&& result.FunctionResult!=null) Debug.Log($"function askChat called result: {result.FunctionResult.ToString()}"); else Debug.Log($"function askChat called null results"); }, (PlayFabError error) => { Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}"); }); }
So in the playstream monitor I get this event:
in my unity console I get this log:
"function askChat called null results"
also the objects of the player I'm changing are still empty I think I'm expecting them to change:
thanks in advance for any help.
I have being asking quite a few questions I'm sorry for that. I'm kinda lost I'm not sure if I have being going around through the right track to learn how to use play-fab. I'm hoping I'm like just 1 question away from not needing more help thanks for all the help so far.