powered by Jive Software

How can I recieve a message from IM server?

hi everyone!

I am a newer of smack and I use jive_messenger as a server ,and smack as a client package.

I run the code as a java program the code like this:

XMPPConnection con

= new XMPPConnection(“jabber.org”);

con.login(“mtucker”, “password”);



I can send message successful ,but how can I recieve the message!?


Simple. You just needs to add a packetListener to the connection object.


PacketListener messageListener = new PacketListener() {

public void processPacket(Packet packet) {

Message message = (Message)packet;

String from = message.getFrom();

String body = message.getBody();



connection.addPacketListener(messageListener, new PacketTypeFilter(Message.class));

This should do the job.