How To Send Text Chat Message To External Storage

Diarkis Room comes with text chat functionality. Chat data is stored and managed within a room's memory and will not be persisted. If you need to persist the chat data, you need to send chat data somewhere else.

Here, we explain how to send the chat message data elsewhere when a new text chat message is received on the server.

// import,

// This exposes all room commands
// This exposes all room support commands including text chat

// Make sure you write this block of code AFTER calling room.ExposeCommands() and roomSupport.ExposeCommands()
// By doing so, we make sure sendTextChatData function is executed after the text chat is handled
server.HandleCommand(util.CmdBuiltInVer, util.CmdRoomChatSync, sendTextChatData)

// This function handles the sending of incoming text chat message
func sendTextChatData(ver uint8, cmd uint16, payload []byte, userData *user.User, next func(error)) {
if len(payload) == 0 {
// Empty data, ignore it
textChatData := string(payload)
// Send textChatData somewhere else here!