powered by Jive Software

Packet Listener

Hello all,

I am trying to impl packet listener, such that when ever somebody tries to initate chat, I got the event for it.? Not sure PacketListener is the right choice. I can send the messages and initate chat myself, but I’m not getting event when somebody else tries to initate chat with me.I’ve code like this:

connection.addPacketListener(new MyPacketListener(), new OrFilter());

class MyPacketListener implements PacketListener {

public void processPacket(Packet packet) {

if (packet instanceof Message) {

Message msg = (Message) packet;

// Process message

System.out.println("Subj: “msg.getSubject()”, Body: "+msg.getBody()

*", Type: "*msg.getType());

} else {

System.out.println("=== Got a packet === "+packet);




Use the ChatManager to register a ChatManagerListener. This will notify you when a chat object is created either locally or remotely. Then, in that listener method attach a MessageListener to the newly created chat, which will get called whenever a new message arrives.

When a new chat is created you should cache it and then when you need to send a chat, try to use a cached one first, otherwise create a new one.

Hope this helps,