简体   繁体   English

XMPP Smack API RosterListener +数据库更改

[英]XMPP Smack API RosterListener + Database Change

I'm writing an XMPP client in Java using the Smack API. 我正在使用Smack API用Java编写XMPP客户端。

I registered a roster listener for each user, and the Smack API calls... 我为每个用户注册了一个名册侦听器,并且Smack API调用了...

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? 是否有人知道如果数据库更改但不是通过Smack API createEntry()方法更改此侦听器是否会关闭?

Basically, I want to tie the XMPP client to a website. 基本上,我想将XMPP客户端绑定到网站。 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. 我希望不设置套接字或使用PHP登录XMPP服务器,而是希望修改数据库即可。

Will this work or is there another way to handle this without the client constantly polling the database for changes? 这样做是可行的还是有另一种方法来解决此问题,而无需客户端不断轮询数据库中的更改?

Changing the database has nothing to do with Smack directly, since it is a client library. 更改数据库与Smack直接无关,因为它是一个客户端库。 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. 我不知道是否有任何xmpp服务器实际上具有此功能。

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. 直接更改数据库似乎并不可行,因为您很可能会使XMPP服务器和数据库不同步。

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. 对于客户端轮询数据库,如果XMPP服务器(甚至可能是Web服务器)正在使用数据库,则客户端可以直接访问数据库似乎不是一个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM