Hey everyone!
So I was having trouble with Roster’'s and I found a related thread:
http://www.jivesoftware.org/community/thread.jspa?threadID=12929
The issue is with the way the Roster stores JID’‘s. Here’'s a snippet of a unit test to see what I mean:
Roster roster = this.xmppConnection.getRoster();
assertNotNull(roster);
String jidWithoutResource = “junit@” + this.xmppConnection.getHost();
roster.createEntry(jidWithoutResource, jidWithoutResource, null);
// entry will NOT be null
RosterEntry entry = roster.getEntry(jidWithoutResource);
assertNotNull(entry);
roster.removeEntry(entry);
/code
Do you think this will succeed? It actually won’'t. It will fail at the last line on the call to removeEntry (specifically, XMPPException: No response from the server.).
What about this?
Roster roster = this.xmppConnection.getRoster();
assertNotNull(roster);
String jidWithResource = this.xmppConnection.getUser();
roster.createEntry(jidWithResource, jidWithResource, null);
// entry will be null
RosterEntry entry = roster.getEntry(jidWithResource);
assertNotNull(entry);
roster.removeEntry(entry);
/code
This doesn’‘t work either, actually. It’'ll fail on the assertNotNull.
In the thread I mentioned before, the issue of whether the Roster should contain/accept full JIDs (including resource) came up. According to RFC3921, section 7.1:
“The “key” or unique identifier for each roster item is a JID, encapsulated in the ‘‘jid’’ attribute of the element (which is REQUIRED). The value of the ‘‘jid’’ attribute SHOULD be of the form user@domain if the item is associated with another (human) instant messaging user.”
The JID without a resource makes sense if you’'re doing (human) IMing, but our XMPP network uses them extensively.
Can someone please explain this to me, and how I should go about using the Roster properly? Thanks!