Problem with Occupants

My first issue is this: There is no way to get a Collection of occupants from a multiuser chat. You can get an iterator but if i wanted to get say a collection to throw in a vector or what have you the only way to do this is with the iterator.

Then say I am watching the presence packets coming from a multiuser chat and I come across a new “occupant” i do a getOccupant(packet.getFrom()) and I get an Occupant i then throw this in my vector, since MUChat gives me a new instance of occupant each time and it has no equals method the contains() on my vector wont work so I may end up putting the occupant in there several times.

Thanks for your time,

Alex

Hey Alex,

Thanks for your input.

My first issue is this: There is no way to get a

Collection of occupants from a multiuser chat. You

can get an iterator but if i wanted to get say a

collection to throw in a vector or what have you the

only way to do this is with the iterator.

Some time ago the Iterator vs. Collection design was discussed. A future version of Smack may modify the current approach and return unmodifiable Collection instances instead of Iterators.

Then say I am watching the presence packets coming

from a multiuser chat and I come across a new

“occupant” i do a getOccupant(packet.getFrom()) and I

get an Occupant i then throw this in my vector, since

MUChat gives me a new instance of occupant each time

and it has no equals method the contains() on my

vector wont work so I may end up putting the occupant

in there several times.

Good point. I created the issue SMACK-54 for this problem.

Thanks,

– Gato

I’'ve thought of another issue that could arrise with the way that occupants are being handled. Since I am being passed a new Occupant object, and this object is then not being updated by the multiuser chat, any role, nickname, etc. information is not being kept up-to-date. Now if this is the desired functionality i will just keep track of it myself but then I think it should be noted accordingly in the javadoc to help avoid confusion.

Thanks again for your time,

Alex