文档

​
​

Development

User Acquisition

Monetization

工业

Vivox Unity SDK

Vivox Unity SDK

Vivox
​
​
Vivox Unity SDK
  • Overview
  • Get started
  • Release notes
  • Developer guide
    • Set up your project
    • Create voice and text channels
    • Messaging
      • Channel messages
      • Message metadata
      • Chat history
      • Edit and delete messages
      • Directed messages
      • Offline direct messages
      • Anti-flooding
      • Large text channel setting
      • Retrieve Conversations list
      • Set Chat Markers
    • Player management
    • Device management
    • Audio management
    • Mobile development
    • Text-to-speech
    • Speech-to-text
    • Real-time recording
    • Server-side-recording
    • Troubleshooting
  • Tutorials
  • Reference
  1. Vivox Unity SDK 文档

获取对话列表

How to retrieve a list of conversations for a player.
阅读时间2 分钟
最后更新于 8 个月前

可以获取用户的对话列表。对话是指用户发送消息或私信 (DM) 的频道。可以使用此 API 填充频道或 DM 列表,以便用户查找其活动聊天。
注意
返回的对话列表按最近的活动进行排序。结果中先显示包含较新消息的对话。
要获取对话列表,请登录到应用程序,然后使用
await VivoxService.Instance.GetConversationsAsync();
发出请求。此方法返回
VivoxConversation
对象的集合,每个对象表示一个 DM 或一个频道对话。
以下代码的示例说明如何获取用户的对话列表。
// 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; }}
注意
根据返回的
VivoxConversation
的
VivoxConversation.ConversationType
,
VivoxConversation.Name
将是另一个用户的 PlayerId,或者是频道的唯一频道名称。在这两种情况下,
VivoxConversation.Name
是两种对话之一的唯一标识符。

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。


    报告此页面的问题