powered by Jive Software

Simple chat problem

There is probably a simple answer to this, but:

If I do like:

Chat c = conn1.createChat("user@server.org");

c.sendMessage(“Hi”);

System.out.println(c.nextMessage().getBody());

And in the other end:

conn2.addPacketListener(new PacketListener() {

public void processPacket(Packet packet) {

Chat chat = conn2.createChat(packet.getFrom());

chat.sendMessage(“got it”);

}

}, new MessageTypeFilter(Message.Type.CHAT));

But nextMessage() never returns. If i put a packetListener on conn1 it works, but nextMessage() doesn’'t.

Here goes the question: How do I reply to a chat, in a way that nextMessage() will understand?

i guess your problem is Chat chat = conn2.createChat(packet.getFrom());

it should be Chat chat = new Chat(conn2,packet.getFrom(),((Message)packet).getThread());

cu

Herbert Poul

http://goim.sphene.net

Thanks a lot

Maybe this should be in the basic tutorial, as I would never have thought of that myself

Is it the same thing about groupchat instances? Hm, I’'ll try it out.

Btw, could creation of a chat instance be copied to XMPPConnection, so that I would be able to do like: conn2.createChat(packet.getFrom(), ((Message)packet).getThread());