Text Chat Feature With Room Class

Room class offers text chat functionalities.

Diarkis Room supports text chat functions.

The text chat data will be stored and managed per room on the server memory.

In order to persist chat message data, you must send the chat data from rooms to external database or storage. Read here to learn how to send text chat data to external storage.

Sending Text Chat Messages

// Capture the response from the server
room.OnChatSyncResponse += (bool success, byte[] payload) =>
{
// If success is false, delivery of the chat message has failed.
// payload may contain error information.
};

// Send the message to others
room.SendChatMessage("Hello there!");

Receive Text Chat Messages

You receive text chat messages via the event listener callback. The callback will pass an instance of RoomChatData that contains the sender of the text chat, timestamp, and its text message.

public class RoomChatData
{
// Sender user ID
public string SenderUID;
// Timestamp of the chat message in milliseconds
public long Timestamp;
// Text chat message
public string Message;
}
room.OnChatSync += (Diarkis.Modules.Room.RoomChatData chatData) =>
{
// Handle the text chat message here
};

Retrieve The Chat Log

When joining a room, you may need to retrieve all text chat messages that were sent before you joined the room.

Here is how to do just that.

// Receive the chat log from the server with this event listener callback
room.OnChatLog += (List<Diarkis.Modules.Room.RoomChatData> chatLogList) =>
{
// Handle the chat log
};

// Ask the server to get you the chat log
room.GetChatLog();