I'm not sure how to properly listen for MultiUserChats, since there are apparently two different ways to listen for them.
The first way is to add a MessageListener for each room, like this:
MultiUserChat muc = new MultiUserChat(connection,"MyGroup");
muc.addMessageListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
// TODO Auto-generated method stub
}
});
The second way is to listen as you would for normal single-chat messages:
PacketFilter filter = new MessageTypeFilter(Message.Type.groupchat);
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) {
Message message = (Message) packet;
if (message.getBody() != null) {
final String fromName = StringUtils.parseBareAddress(message.getFrom());
final String Rtext = message.getBody();
Considering that I am also listening for file transfers, could you please help me figure out which way is the proper way?
is the correct way.
Since the Original Codes both Had Bugs, i used This code: