question

Ion avatar image
Ion asked

Best practices Photon Chat history + Groups

Hello!

I wanted to ask about the best practices using guilds + photon chat.

I am planning to save the history messages in group files, is this a good practice?

My idea is to load the history when a user subscribe to a chat channel, then load the current channel messages (if are some in cache or similar). Then, i can compare the date when i receive a new message in "GetMessages", and decide if i should "add" to the current chat window.

(just for explaining a little)

Then, each user executes a cloud script when sends a new message to add the message to the history file of the guild.

Thanks in advance.

1 comment
10 |1200

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

Hamza Lazaar avatar image Hamza Lazaar commented ·

hi @Ion

PlayFab does not support Photon Chat WebHooks currently.

1 Like 1 ·
pfnathan avatar image
pfnathan answered

Saving the history messages in group files is not a good practice, this is not a recommended way to use Cloud Script, If you want a way to persist chat it would need to have a room destruction webhook. Your description on idea would need to reworks Photon chat, a chat that saves the chat history when the room is cleaned up and loads the history only when the chat room is created would be fine, but trying to save on every message is not.

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

Ion avatar image Ion commented ·

I understand. So i need photon cloud in order to create room and use webhooks ?

I could trigger a destroy room as you say, and save a chat history then?

There is not a way to use only photon chat? Without photon cloud.

Thanks!

0 Likes 0 ·
brendan avatar image brendan Ion commented ·

As Hamza pointed out, we're not set up to support Webhooks from Photon Chat. Saving your chat channel is technically possible using the Entity File system, but since Photon Chat and Photon Realtime do not provide you with server-authoritative logic, coordinating the save/load would be tricky. Your best bet for now would be to simply use Redis to store and retrieve the chat data.

0 Likes 0 ·
Ion avatar image Ion brendan commented ·

Would be this a good start point?

https://github.com/ServiceStack/ServiceStack/wiki/Secure-SSL-Redis-connections-to-Azure-Redis

I could send each message to redis cache and get all the messages when a user is subscribed? (as a summary)

Sincerely, I have no experience in this, so thanks for the help.

0 Likes 0 ·
Show more comments
Show more comments
Kamil avatar image
Kamil answered

Hello everyone,

I have new question to this idea.

My plan is also to save the chat channel history to group files, but in a simpler way. I want to execute CloudScript function (or use Photon webhooks, but I don't know how to do this yet) only when the last player leave the chat channel (because then Photon removes the public channel and only at that point the message history is lost). And the chat history would only be loaded from that file when the first player subscribed to the group's channel.

By default, Photon includes the sender's nickname in the text of the message sent, so I only need to save and load a simple string. Chat history would be kept for 7 days.

Is it possible without additional external services?

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.