powered by Jive Software

Undestanding aSmack

Hello Geeks,

I am rookie XMPP developer and have read XMPP definitve guide , wikis many dev forums but there are few things that i am not able to understand.

May be this is a very small question but i want to be clear before i start developign .

  1. What is PubSub , exactly in what live scenarios of a chat messenger app will this feaure be used. because i see other classes for login , register , listners, rosters , chat managers , bytstreams etcc… which are clear to be when those are to be used but not PubSub

  2. As its a chat program … this will be threaded … and i want to under stand if my approach is correct

Create one MainAndroid service … which will later invoke 4 theards

1st thread for Connection , roster listners

2nd for Chat manager and listners

3rd for Fileuploads and downloads

4th gneral for packet and other listners and exchnages

Is this a good apporach or its all crap.

How do i use listners in a java program for eg i tried to use RosterListener but it was not actully listening for the changes is it because the program was not threaded ? bcz i just wrote in followin fashion where it does work but not in realtime is bcz its not threaded ?

Can anyone help me with a sample code for implementing a listner in realtime.

Class XYX

{

Connect()

Register()

Login()

FetchRoster(

RosterListner (

onadd()

on update()

etc…

);

)

}

I am slowerly moving from SAP to java/android programming so may be these are too basic questions but any help from the community will be really helpful…

I am based in Pune , India … we can meet for a beer if any one out there.

Thanks

Jeet

What is PubSub , exactly in what live scenarios of a chat messenger app will this feaure be used.
Why do you think that PubSub will be used in a chat scenario? It could be used for that, but first it’s just an (abstract) concept of publish subscribe.

Create one MainAndroid service … which will later invoke 4 theards
A service is always a good idea when it comes to XMPP on Android. It’s not required that you create the threads.

Can anyone help me with a sample code for implementing a listner in realtime.
No, I can’t and wont give you sample code. It’s important that you understand how the code works. I can only really recommend having a look at the various open source implementations using aSmack.

Hey Flow ,

Thanks a lot for your quick response.

However I read abt pubsub and as you said its abstract that is what is confusing me.

Because i see that there are pubsub_node , pubsub_options and other pubsub tables in ejabberd.

Wehn i connect and subscirbe to other user those pubsub tables have entires when i do it from Pidgin how ever when i do it using smack with roster.creatEntery() i dont see any rows in the pub sub table.

So wanted to know what scenario we would use these classes a brief idea will really help

Also when i am creating a small program as

Class XYX

{

Connect()

Register()

Login()

FetchRoster(

RosterListner (

onadd()

on update()

etc…

);

)

}

its not updating roster users prsence and roster list on real time i have to re-run the program / method to get the update was not sure what wrrong i am doing …

  1. What is PubSub , exactly in what live scenarios of a chat messenger app will this feaure be used. because i see other classes for login , register , listners, rosters , chat managers , bytstreams etcc… which are clear to be when those are to be used but not PubSub

I am slowerly moving from SAP to java/android programming so may be these are too basic questions but any help from the community will be really helpful…

In the context of a chat messenger, PubSub is probably best used as PEP, which in return is used to publish personal stuff like your avatar, your activity, your mood, your location, etc.

E.g. you publish your location and all your contacts now see, where you are.

subscirbe to other user those pubsub
XMPPs roster subscribe mechanism is not related to PubSub. Those are two orthagonal concepts of XMPP.

They are still a little bit related. E.g. if I have a presence subscription, I can also have automatically a pubsub subscription to the same user. That’s how PEP works.

See http://xmpp.org/extensions/xep-0060.html#presence

Right, that probably explains why ejabberd’s pubsub tables are chagned after roster subscription.

Thanks CSH for making it clear…

So what is the differnce in other classes eg…

I can update my status/Avatar using presnece and Vcard classes too… does this mean in this case the subscribers will nto be notfied ???

Also i was readiing about PubSub and i see there are Node , collection nodes etc… the XMPP.org doesnt have details abt the node and other pubsub components do you know here can i read the details abt the same …

Thanks

Jeet

I can update my status/Avatar using presnece and Vcard classes too… does this mean in this case the subscribers will nto be notfied ???

Yes, but for this case, there’s http://xmpp.org/extensions/xep-0153.html

Unfortunately XMPP is not very clear here, and offers 2 possibilities, due to historical reasons.

Also i was readiing about PubSub and i see there are Node , collection nodes etc… the XMPP.org doesnt have details abt the node and other pubsub components do you know here can i read the details abt the same …

All I know is the spec (which is probably the most complex one and not easy to understand).

http://xmpp.org/extensions/xep-0060.html

Ok so i can use Pubsub as well as other mechanisma and they should work fine ( i suppose) thanks for the help CSH and Flow