4

we've got an XMPP server (OpenFire) and a custom client based on the Java Smack XMPP stack. We're using manual subscription acceptance, so clients have to exchange subscribe and subscribed presences.

As noted in the RFC, subscribe presences ("I want to subscribe to your presences") are stored by the server and resent every time the user logs in until he answers them. Unfortunately, the same does not seem to be true for the answers ("subscribed" or "unsubscribed"). If the original requester if offline when the other users answers the subscription request, he does not receive the answer. I could not find anything in the XMPP RFC about expected behaviour of the server.

What can I do? Is there something I might have missed? Or is there a standard way to implement this use case?

This OpenFire forum post suggests that the behaviour I'm experiencing is the desired one...

Thanks for all pointers, Florian

4

2 回答 2

1

您可以使用两种方法来确定订阅状态:

  1. 检查请求用户的名册。如果名册包含相关实体的项目,其订阅属性为“to”或“both”,则您已订阅。
  2. 第二种选择是向服务器发送另一个订阅数据包;如果他们已经接受了出席请求,服务器应该代表其他用户立即响应订阅。
于 2011-01-05T10:04:30.257 回答
0

所以Alice想要订阅Bobs的出席信息并发送订阅请求。服务器将向Bob发送通知,直到他回答yesno。你现在的问题是,如果 Alice 离线,服务器不会通知Alice,而Bob会对请求做出反应。所以爱丽丝会碰巧得到鲍勃的回答。

如果Bob同意交换出席信息,Alice会在她的花名册上注意到这一点——她会看到Bob的出席(离开、空闲……)。否则,她将不知道该请求是否仍在等待中,或者Bob是否拒绝了她的请求。

可以通过实现自定义模块并将其添加到您的 openfire 服务器来更改此行为。Openfire 对此有一个 API。

该模块将对确认消息做出反应,并可以将所有未决或最近确认的订阅消息的状态消息发送给订阅者(每次登录时)。您的客户端代码可以处理这些消息并以适当的方式将此状态呈现给订阅者。

于 2011-01-05T08:59:40.487 回答