gpt4 book ai didi

XMPP 名册状态、自定义名册和未知用户之间的消息传递

转载 作者:行者123 更新时间:2023-12-04 13:49:20 25 4
gpt4 key购买 nike

我对 XMPP 很陌生,最近决定尝试在移动平台上制作一个 IM。关于 XMPP 我有几个问题,在最近的阅读之后我似乎无法找到答案(我正在考虑使用 ejabberd 或 Tigase 作为服务器,因此以下问题将假设服务器端是其中之一):

  1. 我读到在 XMPP 中,将另一个用户添加到名册中是通过客户端向服务器发送名册设置请求完成的,然后服务器将添加订阅状态为“from”和“to'分别发送给请求客户端和被添加的客户端。另外,要使名册项的订阅值变为“两者”,被添加的用户需要接受发送的请求。这是正确的吗?

  2. 在我的理解中,一个用户通过 XMPP 中的 JID 识别和添加另一个用户,如果我把它放到 WhatsApp 的案例中,它就是用户的电话号码。这是正确的吗?

  3. 是否可以让服务器自定义客户端的花名册?例如,服务器将处理所有使用 IM 的客户端,并根据某种逻辑返回一个花名册,例如他们可能认识的人,而不仅仅是用户添加的联系人?为了更清楚地说明这一点,您可能认识 Facebook 的人。因此在这种情况下,每次客户端登录并请求花名册时,服务器都会返回用户可能会发现他们想与之交谈的人的列表。

  4. 根据之前的理解,假设A发送了添加B的请求,但B还没有接受,用户A是否可以看到另一个用户B是否在线?在 B 接受请求之前向 B 发送任何消息怎么样?

感谢您的帮助!

最佳答案

I've read that in XMPP, adding another user into roster is done by a client sending a roster set request to the server, then the server will add a roster item with subscription state of 'from' and 'to' to the requesting client and the client being added respectively. In other to have the roster item's subscription value to become 'both', the user being added need to accept the request sent. Is this correct?

有两个位。一个是添加到花名册,另一个是获得状态订阅。在线状态订阅是通过发送在线状态订阅请求建立的(这样做时联系人将自动添加到名册中)。另一方面,花名册集会操纵您的花名册,但不会导致在线订阅。

In my understanding, one user identify and add another user by JID in XMPP, which if I put this into WhatsApp's case, it is the user's phone number. Is this correct?

对于 XMPP 情况,是的,寻址是通过 JID 完成的。我不知道 Whatsapp 的地址是如何工作的。

Is it possible to make server customise client's roster? For example, the server would process all client using the IM, and return a roster based on some logic, e.g. people they might know each other, instead of only user's added contacts? To clarify this more clearly, it is like Facebook's people you might know. So in this case, each time a client log in and request roster, the server will return a list of people the user might find they would like to talk to.

在封闭环境中进行服务器定制是可能的。它在公共(public)网络上不起作用,因为存在订阅是双向的,你最终会得到一个在线时看不到的人名册。另一方面,您可以很容易地设置一个用户搜索服务,返回建议,客户可以随意添加。

From the understanding before, is it possible that a user A can see if another user B is online or not, given that A sent a request to add B, but B has not yet accepted? How about sending any message to B before B accepted the request?

只有当 B 接受了 A 的出席订阅后,A 才能看到 B 是否在线。在标准 XMPP 中,您不需要状态订阅来发送消息(尽管某些部署可能会改变这一点,例如 Google 的部署)。

要了解这些类型问题的概述,我建议阅读 XMPP The Definitive Guide (O'Reilly) (免责声明,我是作者之一),或者相关的RFCs(6120、6121、6122)和XEP系列(自然,我觉得这本书更易读)。

关于XMPP 名册状态、自定义名册和未知用户之间的消息传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26172853/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com