powered by Jive Software

Trouble with MultiUserChat and setting Presence

Hi all,

Would appreciate it if someone can help me understand what I’m doing wrong.

I’ve got a UserStatusPanel class that implements PacketListener so that I can listen for Presence updates. This does nothing fancy and is a standard implementation as follows:

public void processPacket(Packet XMPPPacket) {   if(XMPPPacket instanceof Presence){     Presence p = (Presence)XMPPPacket;     //Do Stuff here

(I add this Class to the MultiUserChat participantListener list and as a ParticipantStatusListener for other purposes)

In testing, I’ve got a pidgin client that I’m setting to away/dnd/available etc and I’m successfully receiving updates in my simple little program.

My problem is when I use my simple program to set my own Presence. Again this is done really simply:

Presence presence = new Presence(Presence.Type.available, "Online", 1, Presence.Mode.available); //$NON-NLS-1$
XMPPServerConnection.sendPacket(presence);

The server receives the presence update as I can see the change in the admin panel but I’m not receiving the update in my program at all. I can’t figure out what Pidgin is doing differently but if anyone has any ideas why Pidgin works but the above code doesn’t I’d really appreciate it.

I should probably add, I’m not subscribed to receive anyone’s presence updates but it still works when Pidgin sends updates. I get the feeling I need to send the packet to the MultiUserChat room but I can’t see anything obvious that does this as MultiUserChat only lets you send a string or Message.

Cheers,

Wayne

Apologies, managed to find this myself by looking again through the SVN.

For future reference all you have to do is use Presence.setTo e.g. :

Presence presence = new Presence(Presence.Type.available,
                                   "Online", 1, Presence.Mode.available);
presence.setTo("[chat room name]@[chat room service]/[My Nick Name]");
XMPPServerConnection.sendPacket(presence);

So in my case I set presence.setTo(“testroom@conference.elastix/wayne”);

That was all it took to fix.

Apologies for wasting anyone’s time.