Retrive offline messages

can any body give me idea about how to retrive offline msges,i use all 4 classes OfflineMessageHeader,OfflineMessageRequest,OffLineMessageInfo n OffLineMessageManager,

but i can,t understand how to retrive offline messages.

Hi inlove,

use this code


import java.util.Iterator;

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.packet.Message;

import org.jivesoftware.smackx.OfflineMessageManager;

public class OfflineTest {

public static void main(String[] args) throws Exception{

ConnectionConfiguration cc = new ConnectionConfiguration(“localhost”,5222);

cc.setSASLAuthenticationEnabled(false);

XMPPConnection con = new XMPPConnection(cc);

// con.addPacketListener(new PacketListener(){

//

// public void processPacket(Packet pack) {

// System.out.println("Paket : "+pack.toXML() );

// }

// },null);

con.login(“jitu”,“jitu”,“res”,false);

OfflineMessageManager omm = new OfflineMessageManager(con);

System.err.println(omm.getMessageCount());

// OfflineMessageRequest omr = new OfflineMessageRequest();

// con.sendPacket(omr);

Iterator itr = omm.getMessages();

while(itr.hasNext())

{

Message m =(Message) itr.next();

System.err.println(m.getBody());

}

}

}

hi,

i already use this code but i found a problem that messagecount value is always 0, i don’'t understand why it is happen,there is no problem in code as i think is there any other settings to retrive the offline msges,

Hi inlove,

Are you using this line for login ?

con.login(“user”,“pass”,“res”,false);

If no then you have to use this because here you are not sending your presence to the jabber server.

You will be logged in as an invisible to the Jabber server using below login() method.

You can do proper handling of the Offline messgaes(using above code) before sending presence to the Jabber server.

con.login(“user”,“pass”,“res”,false);

If you are using below to login, then all the offline messages are sent to the client when he sends the presence to the jabber. Below login() method sends the presence to the Jabber server after successfully login. So you can only get those offline messages in PacketListener().

con.login(“user”,“pass”);

<
**+**Regards,

Jitendra

Thank you, jchittoda !

It’'s OK!

Hi

i dont understand what type of login i have to use…

i try with myconnection.login(user,pass,res,false); but sometimes i receive offline messages, but the other times no.

could someone could post a complete example of a smack client that could receive offline message, or a full explain

of how do this?

thanks

bye

v.harkonnen

Hey ,

Under the test folder check the org.jivesoftware.smackx.OfflineMessageManagerTest test case to find working example of offline messages. BTW, are you using Wildfire when you observe the random problem? If you do can you provide me the steps (or working code) to reproduce that problem?

Thanks,

– Gato