Chat history
Retrieve and manage chat message history.
Read time 1 minuteLast updated 7 months ago
Channel text message history
Vivox allows for users to access the history of a channel's text activity using , with being the name of the channel to request the history of, being the number of messages to return at a maximum (10 is the default), and being an optional parameter which can do things like specifying a word or phrase contained in the messages, a specific PlayerId sender of the messages, or times to query before or after. More specific information on s can be found in Chat history query options.
VivoxService.Instance.GetChannelTextMessageHistoryAsync(string channelName, int requestSize = 10, ChatHistoryQueryOptions chatHistoryQueryOptions = null)channelNamerequestSizechatHistoryQueryOptionsChatHistoryQueryOptionThe messages returned in are listed in order from newest message to oldest message.
IReadOnlyCollectionThe following code snippet is an example of pulling at most recent 25 messages from a set LobbyChannelName, then logging the sender's display name and the message in order from oldest to newest, without using the optional ChatHistoryQueryOptions.
public async void FetchHistoryAsync(){ var historyMessages = await VivoxService.Instance.GetChannelTextMessageHistoryAsync(LobbyChannelName, 10); //Reversing the messages so they display from oldest to newest var reversedMessages = historyMessages.Reverse(); foreach(VivoxMessage message in reversedMessages) { Debug.Log($"{message.SenderDisplayName}: {message.MessageText}"); }}