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 some
Here, we explain how to send the chat message data elsewhere when a new text chat message is received on the server.
// import github.com/Diarkis/dairkis/server, github.com/Diarkis/diarkis/room github.com/Diarkis/diarkis/util// This exposes all room commandsroom.ExposeCommands()// This exposes all room support commands including text chatroomSupport.ExposeCommands()// 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 handledserver.HandleCommand(util.CmdBuiltInVer, util.CmdRoomChatSync, sendTextChatData)// This function handles the sending of incoming text chat messagefuncsendTextChatData(ver uint8, cmd uint16, payload []byte, userData *user.User, next func(error)) {iflen(payload) ==0 {// Empty data, ignore itnext(nil)return } textChatData :=string(payload)// Send textChatData somewhere else here!next(nil)}