I’m tring to dev a xmpp client with smack lib and I met with one problem on pubsub.
According to http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/ index.html , I’ve succeed in creating nodes on service and subscribing nodes.Then according to xep-0060,when Publisher publishes a item on the node,Subscribers should receive event notifications .But on my client ,how can i get the event notification and deal with it?
Thanks in advance, and i am looking forward positively.
As I understand,your code is meant that when user subscribes to the node,the node will send the notification of the latest items to user .But what i want is , a publiser pubs a new item on the node and then the user who subscribe to the node will get the event notification.My confusion is how to get the event notification and deal with it.
Once you subscribe, you will typically be sent the last item that was published to the node and any messages published after your subscription. The code node.addItemEventListener(new ItemEventCoordinator()); is how you setup a listener that can handle those messages, so it is logical to put the listener in place before you subscribe so you don’t miss any messages.
If you want the messages that are already on a node (assuming it is persistent) then you have to explicitly get them via ***node.getItems()***.
I have subscribed to the node and added a listener in place before I subscribe.So after a new item is published on the node,service will send notification to subscribers.
But as the subscriber,what should I do to receive the notification and obtain the information i need(such as the information of published item in it)?
i have used the above code but my ItemEventListener is not able to get called ,i dont know what is the reason. when my node.subscribe("james@example.com"); get called i am getting successfull message from the server which indecates that the JID is subscribed now. but after that i am not able to see any message or published items , not even in a debug mode
so far i am able to create node , publish node and get the node successfully but after subscribing i am not be able to get the items. i read all threads so far but none of them solved my issue , plz help