views:

160

answers:

4

Hi,

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 ?

+1  A: 

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.

Julien Genestoux
Thanks for the reply . I also tried MUC with strophe and its working just fine. But in this case, what i want is a notification system eg suppose there is a question-answer module and i post a question, if user1 answers this then i get a notification. Then if userB answers, both me and userA get a notification. Most importantly, if I am online when an answer is posted, i should see a popout without me clicking on anything. How about sending a headline message to all jids using a server side xmpp lib such as xmpphp and handling the message on client side using strophe ?
naiquevin
to clarify my above question -- I tried sending a message using xmpphp to a jid and receiving it using strophe client and it works. what i am not sure is whether this method will give any problems if a message is to be sent to many people.
naiquevin
+1  A: 

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....

Abhinav Singh
Thanks for the reply..the problem is that i have to handle different kinds of notifications. In some cases, pubsub seems to be the ideal solution but not for all of them .Thats why I was thinking of sending notification messages manually as a single solution for all.
naiquevin
thats not the preferred way i must say, since as your application load starts to increase this approach will not scale.Better to let jabber server do this broadcasting stuff on your part, you just instruct the jabber server what/when/whom notification should be broadcasted....
Abhinav Singh
+1  A: 

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 ;-)

Chuk Lee
Thanks for the reply, will check PEP.As per my requirement, the notification needs to be published to any one who may or may not be in my roster. Suppose we consider this particular thread, and if both abhinav and chuk lee are in my roster but they are not in rosters of each other, inspite of that when chuk lee answers, a notification should go to abhinav because he has answered before. Also the text that goes to abhinav and me (the quesion author) should be different.
naiquevin
Then I suggest you use MUC approach by using a chatroom as pubsub node. But carry the data in a separate namespace in <message>. In that way, your data will not appear in the chatroom. As I say I've yet to find a public server that supports pubsub.
Chuk Lee
+1  A: 

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.

Robin
Indeed. Pubsub is so general, that anything that even remotely describes a publish-subscribe scenario pegs it as a possible use for Pubsub.
Tim