powered by Jive Software

Listeners

Hi!

I want to know the difference between Message.next() and packetListner.

if I have in my program both a listener and message.next() where will be the message delivered ? both or just one of them how can I conroll where will be the message delivered?

thanks

Ziv

Hey Ziv,

There is a fundamental difference between using a PacketListener to listen out for new Message Packets being delivered and using Chat.nextMessage()

Basically if you want to listen out for messages and then react to them as they come in such you should attach a PacketListener to the connection and then peform some kind of logic based on the messages as the listener gets them.

use chat.nextMessage will return the next message available in the chat but will block until one is received. You can use Chat.nextMessage(timeout) to specify a time for the method if you need to.

From my dealings with messages between users I’‘ve not so far had a need to use Chat.nextMessage, rather I’'ve just added a class that implements PacketListener and listens out for Packets of Type Message to my XMPPConnection and then performed whatever logic is needed on them.

Hope that helps

Jon

Thaks I also use listenrs but I thought maybe I am wrong…