powered by Jive Software

Group Chat

I can set my presence in normal chat without an issue, but how does one go about setting and recieving their presence in a Group chat. I have routine which lists out the participants.

public String getRoomParticipants(){

Iterator items = groupChat.getParticipants();

while (items.hasNext()) {

String entry = (String) items.next();

Presence userPresence = roster.getPresence(entry);

I suspect this line: Presence userPresence = roster.getPresence(entry); is recieving the usual presence but not the chat presence

Could someone enlighten me.

Thanks again



A few things:

  • That code won’‘t work because you can’'t get the JID of a user in a group chat – just their nick name.

  • There is a method in GroupChat that lets you add a listener for presence packets delivered to the groupchat – you should use that to track presence.



Thanks Matt

I missed that in the docs. Just one more thing, how do I go about sending a presence change of a user in Group chat ?

ie: if I normally create a presence packet and send it jconn.sendPacket(presence); how do I do this for a user in a chatroom ?

ps sorry to ask so many many questions, I’'m almost there though


When you send the #join message to a Chat you are sending an AVAILABLE presence to the room. When you send #leave to a Chat you are sending an UNAVAILABLE presence to the room.

If you want to send other type of presence (e.g. away, xa) you should send your own presence to the room.


– Gato

Thanks for the help Gato

That is exactly the question I am asking. When I set my presence in a normal chat it doesnt affect my presence in a chat room. Programmatically speaking, using the Smack library, what command I use to send a presence packet to a room.

Ie: for arguments sake:

Presence presence = new Presence(Presence.Mode.AWAY);

presence.setStatus(“Im going away now”);



You could use code like the following:

Presence presence = new Presence(Presence.Type.AVAILABLE);
presence.setStatus("I''m busy!");



Hooray thats it!

Thanks Matt