views:

863

answers:

1

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?

A: 

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.

Robin