Chat History query options
Query chat history with various filtering options.
Read time 2 minutesLast updated 2 days ago
ChatHistoryQueryOptions is an optional options model that can be included with a
VivoxService.Instance.GetDirectTextMessageHistoryAsyncVivoxService.Instance.GetChannelTextMessageHistoryAsyncSearchText
Use the SearchText field ofChatHistoryQueryOptionshistoryMessagesvar options = new ChatHistoryQueryOptions();options.SearchText = "Hello, lobby!";var historyMessages = await VivoxService.Instance.GetChannelTextMessageHistoryAsync(LobbyChannelName, 10, options);
TimeStart - TimeEnd
The TimeStart and TimeEnd fields ofChatHistoryQueryOptionsDateTimesDateTimeNote that chat history is only stored for seven days, unless you have enabled Text Evidence Management.var options = new ChatHistoryQueryOptions();options.TimeStart = DateTime.Now().AddDays(-1);options.TimeEnd = DateTime.Now().AddDays(-0.5);var historyMessages = await VivoxService.Instance.GetChannelTextMessageHistoryAsync(LobbyChannelName, 10, options);
PlayerId
ForChannelTextMessageHistoryIReadOnlyCollection<VivoxMessage> GetMessagesFromPlayerAsync(VivoxParticipant participant){ var options = new ChatHistoryQueryOptions(); options.PlayerId = participant.PlayerId; var historyMessages = await VivoxService.Instance.GetChannelTextMessageHistoryAsync(LobbyChannelName, 10, options); return historyMessages;}
Channel-based chat history for blocked participants
You can filter messages from blocked users when formatting thehistory_sessionHistory sessions when blocked participants are involved
A history request can come back empty if all messages in the request are from a blocked participant. In this case, the response contains a cursor indicating that there are more messages in the channel on subsequent pages. The default amount of messages returned per history request is 10 per page. Use the cursor value in the following request to retrieve the next page of messages. The maximum page size argument (Max) shows fewer messages than the number requested if there is a blocked user in the channel. When you request a specific page size for your chat history, be aware thathistory_session