XMPP Smack API RosterListener + 数据库变更
我正在使用 Smack API 用 Java 编写 XMPP 客户端。
我为每个用户注册了一个花名册侦听器,并且 Smack API
public void entriesAdded(Collection arg0) {}
会在每次注意到花名册添加时调用……。
有谁知道如果数据库更改但不通过 Smack API createEntry() 方法是否会关闭此侦听器?
基本上,我想将 XMPP 客户端绑定到网站。 当您将某人添加到网站好友列表时,我希望网站通知客户。 我希望只修改数据库就可以工作,而不是设置套接字或使用 PHP 登录 XMPP 服务器。
这是否有效,或者是否有其他方法可以处理此问题,而无需客户端不断轮询数据库以了解更改?
I'm writing an XMPP client in Java using the Smack API.
I registered a roster listener for each user, and the Smack API calls...
public void entriesAdded(Collection arg0) {}
... each time it notices a roster addition.
Does anyone know if this listener will be set off if the database changes but not through the Smack API createEntry() method?
Basically, I want to tie the XMPP client to a website. When you add someone to the website friends list, I want the site to notify the client. Rather than setting up sockets or using PHP to log into the XMPP server, I was hoping that just modifying the database would work.
Will this work or is there another way to handle this without the client constantly polling the database for changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改数据库与 Smack 没有直接关系,因为它是一个客户端库。 它没有数据库。 数据库将由服务器使用和访问,并且根据服务器的不同,可能有一些功能允许服务器在数据库更改时发布消息。 我不知道是否有xmpp服务器实际上有这个功能。
您应该检查正在使用的服务器的功能,并可能使用服务器本身的扩展来添加名册条目。 直接更改数据库听起来并不像正确的方法,因为您很可能会导致 XMPP 服务器和数据库不同步。
至于客户端轮询数据库,如果 XMPP 服务器和可能的 Web 服务器正在使用数据库,那么客户端能够直接访问数据库听起来不是一个好主意。
Changing the database has nothing to do with Smack directly, since it is a client library. It has no database. The database will be used and accessed by the server, and depending on the server, there may be features that will allow the server to post messages when the db has been changed. I don't know if any xmpp servers actually have this feature.
You should check the capabilities of the server you are using, and possibly use extensions in the server itself to add the roster entries. Changing the database directly doesn't really sound like the way to go, as you will most likely have your XMPP server and database out of sync.
As for the client polling the database, it doesn't sound like a good idea for the client to be able to directly access the database if it is being used by an XMPP server and potentially your webserver.