powered by Jive Software


PacketListener is used for listen the incoming messages and work with them??? how I can use it?


If you want to listen out for messages you could do something like

PacketListener myListener = new PacketListener() {

public void processPacket(Packet packet) {

// do something with your packet here

Message message = (Message)packet;

String from = message.getFrom();

String body = message.getBody();

System.out.println("Message from: " + from + " " + body);




You would then need to add this listener to your connection

connection.addPacketListener(myListener, filter);[/code]

Where filter is the type of filter you want to apply which in this case is for type Message

PacketTypeFilter filter = new PacketTypeFilter (Message.class);[/code]