How to get openfire server time of incoming message

Hi! I’m using smack and openfire to develop a chat application. I’m gonna use following code to get discussion history in a MultiUserChat room.

MultiUserChat muc = manager.getMultiUserChat(roomId);
DiscussionHistory discussionHistory = new DiscussionHistory();
discussionHistory.setSince(lastMessageDate); // the time of last message user received
muc.join(userId, null, discussionHistory, timeout);

And I have a problem here

  1. I think I may not use client time as lastMessageDate because it can be changed by user and it’s not accurate, so how can I get the server receiving time of user’s last message?

  2. Is it possible to let openfire server return a timestamp with every response when receiving messages?

@Henry

I think you made retrieving offline messages.

could you please tell me how to retrieve the offline messages?

Thanks in advance…

@androidBee You can use the code I post. if it doesn’t work you can post your code here to discuss

@Henry, i used the below code to get offline messages. But it gives nothing (always ZERO count)

OfflineMessageManager msgMgr = new OfflineMessageManager(mConnection);

try {

List it = msgMgr.getMessages();

System.out.println(": " + it.size());

System.out.println(msgMgr.supportsFlexibleRetrieval());

System.out.println(": " + msgMgr.getMessageCount());

} catch (NoResponseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XMPPErrorException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (NotConnectedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

could you please help to show the sent and offline messages of the user?

Thanks in avance