This Question is Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (5 pts)
3 Replies Last post: May 12, 2008 12:21 PM by Ish  
Ish Bronze 3 posts since
May 9, 2008
Currently Being Moderated

May 9, 2008 8:19 PM

Help with OpenFire and Smack (Offline message retrieval)

 

Hi everyone,

 

 

I'm having a hard time figuring out how to retrieve offline messags with the Smack API in conjunction with OpenFire. I have sample code that logs in with one user and sends a message to an offline user. I then have the recipient login and try to retrieve the offline messages. At this point, according to the logs, The offline message is sent back immediately after the login and presence is sent. There is no way for me to "catch" this offline message. I tried using the OfflineMessageManager included in the Smack API but by the time I invoke it the offline message has already been sent. Here is my code. Anyone have a working example of how to use OfflineMessageManager?

 

 

Thanks,

 

 

Ish

 

 

 

 

public class TestOfflineMessages {

 

 

 

 

private XMPPConnetion _conn1;

 

 

 

 

public void loginAndRetrieveOfflineMessages()

    {

         _conn1 = new XMPPConnection("localhost");

        try {           

            _conn1.connect();

            _conn1.login("testreceiver@mydomain.com", "pw");  

 

 

            OfflineMessageManager offlineMgr = new OfflineMessageManager(_conn1);       

 

 

            if(offlineMgr.supportsFlexibleRetrieval())

            {

 

             &n bsp;  Iterator<Message> it;

 

             &n bsp;  it = _offlinemgr.getMessages();

 

             &n bsp;  while(it.hasNext())

             &n bsp;  {

             &n bsp;      System.out.println("--- " + ((Message)it.next()).getBody());

             &n bsp;  }

            }

 

 

        } catch (XMPPException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }

 

    }

 

 

}

 

 

 

 

 

 

Sabine Dinis Blochberger Gold 285 posts since
Oct 21, 2005
Currently Being Moderated
May 12, 2008 4:15 AM in response to: Ish
Re: Help with OpenFire and Smack (Offline message retrieval)

Have you tried instanciating the OfflineMessageManager before logging in, after connecting?

More Like This

  • Retrieving data ...