powered by Jive Software

Ugent, why i can receive multiUserChat message

package com.bleum.hydra.bb3.conference;

import org.jivesoftware.smack.PacketListener;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.filter.MessageTypeFilter;

import org.jivesoftware.smack.filter.PacketFilter;

import org.jivesoftware.smack.filter.PacketTypeFilter;

import org.jivesoftware.smack.packet.Message;

import org.jivesoftware.smack.packet.Packet;

import org.jivesoftware.smackx.muc.MultiUserChat;

import com.bleum.hydra.jabber.client.FilterExpression;

import com.bleum.hydra.jabber.client.util.JIDUtil;

public class ConferenceTest {

public ConferenceTest()

{

super();

// TODO Auto-generated constructor stub

}

public static void main(String[] agrs){

XMPPConnection.DEBUG_ENABLED = true;

XMPPConnection con;

try {

con = new XMPPConnection(JIDUtil.serverDomain);

// con.login(“jasper”,“111”);

con.login(“tina”,“111”);

org.jivesoftware.smackx.muc.MultiUserChat muc = new org.jivesoftware.smackx.muc.MultiUserChat(

con, "test@127.0.0.1/Smack");

muc.invite(“jasper”,“Hello”);

Message newMessage = muc.createMessage();

newMessage.setBody(“Hi, I’'m an annoying parrot-bot! Type something back to me.”);

muc.sendMessage(newMessage);

// add filter

PacketFilter msgFilter = new PacketTypeFilter(

org.jivesoftware.smack.packet.Message.class);

MessageTypeFilter mtFilter = new MessageTypeFilter(

org.jivesoftware.smack.packet.Message.Type.GROUP_CHAT);

FilterExpression express = new FilterExpression(msgFilter, mtFilter,

FilterExpression.AND);

PacketListener myListener = new PacketListener() {

public void processPacket(Packet packet){

if(packet instanceof Message ) {

Message mes = (Message)packet;

System.out.println(mes.getBody());

}

}

};

// add listener

con.addPacketListener(myListener,express.expression());

}

catch (XMPPException e) {

e.printStackTrace();

}

}}

I run this program two times by using different account name. The second time I invite the user who was runed first. Then a groupChat room is built. I can send message ,but nothing can be received.

The first thing I see is that there is only one connection.

Cheers,

Alex