Sign In Register

How can we help you today?

Start a new topic

Adding persistent data to a TeamChatMessage. (TeamChatMessage.scriptData?)

According to this document a TeamChatMessage contains a scriptData. 


I have some extra data i would like to attach to messages, as specified in the scriptData of the SendTeamChatMessage that originally created the message. Is this use possible?


The cloud code scripts do not seem to actually have access to the real backend message obj so I do not know how to actually make sure of the documented scriptData on it.


Hi James,


I'm afraid you didn't link to the page properly there. Can you share it again so we can see what you are referring to ? Are you saying you would like the scriptData that was set in the first TeamChatMessage to persist in all future ones for that team ?


Thanks,

Liam

https://docs.gamesparks.com/api-documentation/message-api/teams/teamchatmessage.html


TeamChatMessage

A message sent from a player to an entire team.

View interactive version here

Request Parameters

Parameter Required Type Description
chatMessageId No string The identifier for this message as it appears in the chat history.
fromId No string The player's id who is sending the message.
message No string The message to send to the team.
messageId No string A unique identifier for this message.
notification No boolean Flag indicating whether this message could be sent as a push notification or not.
ownerId No string The id of the owner
scriptData No ScriptData[] ScriptData is arbitrary data that can be stored in a message by a Cloud Code script.

"Are you saying you would like the scriptData that was set in the first TeamChatMessage to persist in all future ones for that team ?"


No. I want to be able to add extra information, beyond the text, to a message object. 


Like for example a challengeid. 


So a player would send a message like "Join my challenge!" but also include the challengeId with that message. Then other players would see that message as a hyperlink that when clicked would already have the challengeId necessary to submit the JoinChallengeRequest. 



Note that I ended up implementing this by encoding everything as a json formatted string in the text field.

Hi James,


Setting the scriptData in the TeamChatMessage Cloud Code and then retrieving it on the client side would also have worked here.


Thanks,

Liam

Well, yes and no.


Yes, I can set scriptData in TeamChatMessage and the client receiving it will also get the scriptData.

But, the data I wish to set is provided by the person who sent the message, and there is no convenient way to route that extra data from the request/response to the TeamChatMessage. 


In my ideal world, there would be a cloud api for getting the server-side 'message object' for a given chatMessageId. Similar to how Spark.loadPlayer(id) or Spark.getChallenge(id) works. Then in the SendTeamChatResponse cloud script I could get it and set the script data.

Plus, its not just the team chat messages send via TeamChatMessage that need this extra information. It needs to be there for those inside a GetTeamChatMessagesRequest as well. So, the information has to actually be attached to the real server-side 'chat message' object, ideally from the moment it is created.

Login to post a comment