powered by Jive Software

Multithreaded client?

Hi, I would like to create a multithreaded client that creates a new thread for every client request. Is this possible to do with smack?

Here is my current code - a simple test class:

import org.junit.Test;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;91

public class SmackTest {
@Test
public void test() throws Exception {
ConnectionConfiguration config = new ConnectionConfiguration(“17.102.86.148”, 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);

XMPPConnection connection = new XMPPConnection(config);
connection.connect();
connection.login(“user1”, “user1pw”, “SomeResource”);

PacketFilter filter = new PacketTypeFilter(Message.class);

PacketListener myListener = new PacketListener() {
public void processPacket(Packet packet) {
if (packet instanceof Message) {
Message msg = (Message) packet;

// process msg…
}
}
};
// Register the listener.
connection.addPacketListener(myListener, filter);

System.in.read();
}
}

Thanks

I found the answer!

http://www.igniterealtime.org/community/thread/28731

Looks like this poster asked my exact same question