我正在尝试检索Archived Messages From OpenFire
请注意:
下面是检索消息的代码:
public MamManager.MamQueryResult getArchivedMessages() {
//org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: feature-not-implemented - cancel
try {
MamManager mamManager = MamManager.getInstanceFor(connection);
boolean isSupported = mamManager.isSupportedByServer();
if (isSupported) {
MamManager.MamQueryResult mamQueryResult = mamManager.pageAfter(JidCreate.from(mUsername + SERVICE_NAME), "2r2Vf-68", 250);
List<Forwarded> forwardedMessages = mamQueryResult.forwardedMessages;
Forwarded d = forwardedMessages.get(0);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
除此之外,我还尝试为OfflineMessageManager
smack 4.2
下面的是离线管理员的代码:
public static void handleOfflineMessages() throws Exception {
OfflineMessageManager offlineMessageManager = new OfflineMessageManager(getConnection());
if (!offlineMessageManager.supportsFlexibleRetrieval()) {
return;
}
if (offlineMessageManager.getMessageCount() == 0) {
String d = "ss";
} else {
List<Message> msgs = offlineMessageManager.getMessages();
for (Message msg : msgs) {
BareJid fullJid = msg.getFrom().asBareJid();
String messageBody = msg.getBody();
if (messageBody != null) {
}
}
// offlineMessageManager.deleteMessages();
}
}
注意:上面的方法并不是我总是抛出任何错误 得到消息计数= 0.在我关注官方的地方 Doc为此。即不发送存在以使所有离线 消息。但未能这样做。
这是官方文档的链接:OfflineMessageManager
任何人都可以指出我做错了吗?
答案 0 :(得分:1)
再次在OF插件中重新加载
监控服务
那一切