powered by Jive Software

Help me with getExtension()

Hi everyone,

I am a newbie of Smack, I wrote the following code:

MUCUser user = (MUCUser) presence.getExtension(“x”,“http://jabber.org/protocol/muc#user”);

But I got the error: java.lang.ClassCastException

I guest, when I use (MUCUser) to set presence.getExtension() to MUCUser object, the error would be catched.

I use Smack 1.5.0, jdk1.4.0 with JBuilderX

Please help me! Thanks in advance!

Hey Chien,

It seems that you need to add the build/resources folder to your classpath. The problem is that the META-INF/smack.providers file is not being found.

Regards,

– Gato

This is a good answer! Thanks Gato so much!

Now, I have another question. Hope you will statisfy me.

How can I get all participants of MUC?

MultiUserChat#getOccupants()

I had tried MultiUserChat#getOccupantsCount(), but the value returned is 0 (Actually, there are more than 1 participant in the room). I do not know what happens.

And now, I have more question, that is:

I want to build a Roster of Room’'s Users, I use joined(String user) to add participants to Roster. When the presence of participants is changed, I use PacketListener to change Roster Node.

I thought that has others solution to solve this instead of my solution. For example, the way to build Roster of Room’'s Users is the same as the way to build Roster of Messenger (use RosterListener).

If anyone knows how to do it, please give me the idea and some codes!

Thanks so much!