기술 자료

지원

Vivox Unity SDK

Vivox Unity SDK

대화 목록 검색

How to retrieve a list of conversations for a player.
읽는 시간 1분최근 업데이트: 19일 전

사용자의 대화 목록을 검색할 수 있습니다. 대화는 사용자가 메시지나 DM(다이렉트 메시지)을 보낸 채널입니다. 이 API를 사용하여 사용자가 활성화된 채팅을 찾을 수 있도록 채널 또는 DM 목록을 채울 수 있습니다. 대화 목록을 검색하려면 애플리케이션에 로그인한 후
await VivoxService.Instance.GetConversationsAsync();
를 사용하여 요청합니다. 이 메서드는 각각 DM 또는 채널 대화를 나타내는
VivoxConversation
오브젝트 컬렉션을 반환합니다.
다음은 사용자의 대화 목록을 검색하는 방법의 예제를 보여 주는 코드입니다.
// The use of `ConversationQueryOptions` is optional and the method can be called without providing it.var options = new ConversationQueryOptions(){ CutoffTime = DateTime.Now, // Point in time to fetch conversations from. Conversations joined after this timestamp will not be present in the query results. This timestamp gets converted to UTC internally. PageCursor = 1, // Parameter if you’re fetching anything but the first page. PageSize = 10 // The number of results returned per page. The default is 10.};var conversations = await VivoxService.Instance.GetConversationsAsync(options);
사용자의 대화 목록을 검색한 후 결과
VivoxConversation
컬렉션을 파싱하여 어떤 것이 DM이고 어떤 것이 채널 대화인지 확인할 수 있습니다.
foreach (VivoxConversation conversation in conversations){ switch (conversation.ConversationType) { case ConversationType.ChannelConversation: // Code for handling channel conversations. // You must be in a channel matching conversation.Name in order to fetch the message history of type ConversationType.ChannelConversation. break; case ConversationType.DirectedMessageConversation: // Code for handling DM conversations, for instance... var directMessages = await VivoxService.Instance.GetDirectTextMessageHistoryAsync(conversation.Name); // Populate UI with directMessages with another user. break; default: break; }}