powered by Jive Software

Presence of user not in Roster

Is there a good way to check the presence of a user not in the Roster?

I figured out a workaround, but its ugly:

Roster roster = con.getRoster();

roster.createEntry(jid, “temp”, null);

Presence presence = roster.getPresence(nodeJid);

roster.removeEntry(roster.getEntry(nodeJid));

Anyone?

You can’‘t, that’'s a security restriction in XMPP. The other person has to sent you a directed presence voluntarily, you can catch that via a packet listener.

anlumo is correct in the general case. One other thing you can do – if the user is on your local server, your local server may support an ad-hoc command to get presence data for that user. For example, Openfire lets you do this if you have an admin account in the server.

Regards,

Matt