powered by Jive Software

MUC Questions

Ok, I’'m destined to make the next release of JBother have MUC support… and I have some, what are probably, dumb questions.

How do I find out what affiliations/roles a user has when I join? I know that you can add a ParticipantStatusListener to the MultiUserChat instance, but I don’‘t get anything when I connect, just when an affiliation or role is changed after I’'m already connected.

Thanks in advance,

Adam

The affilation and role information is in an extension in the presence packets that the muc recieves.

e.g

MUCUser mucusr=(MUCUser) presence.getExtension("x" ,"http://jabber.org/protocol/muc#user");
...
MUCUser.Item mucitem=mucusr.getItem();

You have to watch out for null and empty information though, which makes it a bit tricky.

Feel free to have a look at the source from my client for

some ideas ( https://whisperim.dev.java.net )

HTH Pheet

Ok, thanks. Next stupid question:

How can I tell if someone is changing a nickname instead of someone leaving and then coming back?

The ParticipantStatusListener interface defines a method

public void nicknameChanged(String nickname)

which you can use. You still have to do a bit of work in your psence listener class to get the full picture.

Personally, when recieve a presence for someone not already in the room, I just display a “has entered room” message. When someone changes their nick, I get something like this:

Fred has changed their nickname.

newfred has entered the room.

According to the docs on the MultiUserChat#changenickname method:

Changes the participant’'s nickname to a new nickname within the room. Each room participant will receive two presence packets. One of type “unavailable” for the old nickname and one indicating availability for the new nickname. The unavailable presence will contain the new nickname and an appropriate status code (namely 303) as extended presence information. The status code 303 indicates that the participant is changing his/her nickname.

/quote

One should be able to use this information in the presence listnening class.

HTH, Pheet

Ok, thanks again

Moving right along: how do I modify the ban list in a room?

Hey Adam,

You can ban a user giving a reason (see MultiUserChat#banUser(String, String)) or you can ban a list of users which is useful when doing batch changes (see MultiUserChat#banUsers(Collection)).

To remove the ban of a user you will need to change the affiliation to owner, admin or member. As with banning you can change the affiliation of a given user or of a list of users.

Regards,

– Gato

The documentation makes mention of acquiring a list of bans? Can I do that?

Sure you can. Use #getOutcasts() to get the list of banned users.

Regards,

– Gato

I must be blind. What class is that a method of?

All MUC related stuff is in the MultiUserChat class.

Regards,

– Gato

http://jivesoftware.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smackx /muc/MultiUserChat.html does not show this method. Is it a new addition?

Nevermind - I downloaded the latest nightly, and see the method now. Thanks Gato!

Adam,

Right. These are new features that we added after 1.4.1. So you will need to use the latest CVS code which is quite stable.

Let me know if you need any help.

Regards,

– Gato