The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
Re: Roster/Presence code is broken
[Originally posted by cman]

And in Roster.java we have a line..

LinkedList presenceRecipients = new LinkedList();

But this LinkedList is not used anywhere in the code. Is this the problem? Is
this why the presence/roster system is broken?


Thanks
import-bot (20211) [Avatar] Offline
#2
[Originally posted by cman]

The sample code in the book does not work when I try to add users to my
roster. It does not send my name to the user I am adding to my roster.

I have tried using several Jabber Clients like Exodus.


Thanks
foobar (3) [Avatar] Offline
#3
Re: Roster/Presence code is broken
i have the same problem. any pointer?
foobar (3) [Avatar] Offline
#4
Re: Roster/Presence code is broken
i have the same problem. the presence functionality does not seem to work. any pointers?

thanks.
iain (56) [Avatar] Offline
#5
Re: Roster/Presence code is broken
Hi,

Because the code was developed to illustrate concepts and is not under active development it may be better to work with a full client library. I highly recommend Smack, an open source library:

http://www.jivesoftware.com/xmpp/smack

-iain
foobar (3) [Avatar] Offline
#6
Re: Roster/Presence code is broken
Hi Iain,

Thanks for your post. I was mentioning about the "server" source code which was shipped with the book and not the client. Any pointers would help.

regards.
iain (56) [Avatar] Offline
#7
Re: Roster/Presence code is broken
Ah, ya the server code did have some trouble. I ported it from a database to using in memory collections and I think I might have messed up the implementation in the sample code. I'll try to take a look at it this weekend and see if I can figure out a quick fix.

-iain
PoLe (3) [Avatar] Offline
#8
Re: Roster/Presence code is broken
Hi,

Same problem here, server doesn't manage the rosters as it should, clients as Exodus or Psi messes up the server when they use rosters, hope 3 years later iain figures that "quick fix"!.

By the way, i have found your book very useful for my software engineering project.

Thanks in advance,

Pablo.
PoLe (3) [Avatar] Offline
#9
Re: Roster/Presence code is broken
Hi,

I'll reply to myself. I don't know if there is more errors, but i have found one: In the presence handler no anti-spoofing is set. Some clients as Psi, in order to create a groupchat, send something as:

<presence to='mychat.group@server.com/mynick'>

which results in a null pointer exception because of the 'from' attribute is not sent. To avoid this problem just do the same as we did in the MessageHandler class, add this line:

packet.setFrom(packet.getSession().getJID().toString()); //anti-spoofing

as the first line of the notify method in MessageHandler class.

This should fix all the groupchat problems with the Psi client, and most of the roster problems.

Have Fun,

Pablo.

Message was edited by:
PoLe