Question

I am looking to include two features in my app using xmpp. The first one is a one-to-one chat which is almost complete (using strophe) and the second one is real time notifications just the way it works in facebook. I tried to understand the pubsub system in xmpp but dont feel that it will suit this particular problem. Please correct if wrong, it might be due to not getting the concepts correctly. My requirement is this - There will be predefined events that any of the users can fire and when one does, the others who are online should receive a notification for the same. Further i would also want to check if the user has preferred to receive notifications or not before sending them. What I am not getting here is if pubsub is to be used, where and how do the nodes fit. Can I create just one node which every one else will subscribe to ? In that case how will the subscribers publish their events on it without being the node owner ?

The other method I am thinking of is to send message to the jids of all users one by one with a headline type or with an additional payload say <notif/> for differentiating it from normal messages. Is this method fine taking scalability in to account ?

Was it helpful?

Solution

Pubsub would be an appropriate solution for this case. It handles all your requirements from what I can see. You will need to set up a node for each event type, if you expect to have users subscribe differently for each message type (alternatively filters can be used on a single node, but I think multiple nodes are easier). The node owner can allow anyone to publish to a node, so that is not an issue.

PEP was mentioned, but is not the right solution if you want to publish to users that are not in your roster.

Pubsub will also allow you to define any content type you want for messages or none at all if the simple act of the message transmission is informative enough.

OTHER TIPS

PubSub would work, however, what you describes feels more like MUC (Multi User Chat).

Basically, it creates a chatroom that your visitors can join (maybe not using this verbiage), and then, well, when any of them sens a message to the chat room, all of them get it. You can certainly have configuration where you only allow certain users to publish.

Since you already have a client running on the browser, with Strophe, it should be fairly easy. Just make sure this MUC component is running on your server.

what you are trying to do with xmpphp library, i.e. sending message to multiple jid's when required, is what pub-sub or MUC can do for you. :D Hence depending upon your application type you need to choose one and go ahead experimenting with xmpp, things should get clear as you proceed....

To answer your second question regarding realtime notification, what you need is use PEP instead of pubsub. The main difference between the 2 is that PEP will only publish to those in your roster which is I think what you want. Furthermore I think PEP is more widely supported than pubsub or atleast jabber.org supports it. The only problem with PEP is that it requires Entity Capability support.

I've blogged about it here. Examples are in Java; hope you are not adverse to it ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top