Smack - 请求MAM faling

时间:2017-06-08 16:58:38

标签: ejabberd smack

我在ejabberd 15中使用此代码,现在更新到17.04,现在当我要求MAM时,这只是失败。

    private MamQueryResult queryArchive(MamQueryIQ mamQueryIq, long extraTimeout) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (extraTimeout < 0) {
        throw new IllegalArgumentException("extra timeout must be zero or positive");
    }
    final XMPPConnection connection = connection();
    MamFinExtension mamFinExtension;
    PacketCollector finMessageCollector = connection.createPacketCollector(new MamMessageFinFilter(
                    mamQueryIq));
    PacketCollector.Configuration resultCollectorConfiguration = PacketCollector.newConfiguration().setStanzaFilter(
                    new MamMessageResultFilter(mamQueryIq)).setCollectorToReset(
                    finMessageCollector);
    PacketCollector resultCollector = connection.createPacketCollector(resultCollectorConfiguration);

    try {
        //this line works fine. send and IQ and the response is received
        connection.createPacketCollectorAndSend(mamQueryIq).nextResultOrThrow();
        //This line trigger an exceptions  NoResponseException 
        Message mamFinMessage = finMessageCollector.nextResultOrThrow(connection.getPacketReplyTimeout() + extraTimeout);
        mamFinExtension = MamFinExtension.from(mamFinMessage);
    }
    catch(Exception e) {
        Log.d(Constants.TAG_DEBUG, e.getMessage(), e);
        throw e;
    }
    finally {
        resultCollector.cancel();
        finMessageCollector.cancel();
    }
    List<Forwarded> messages = new ArrayList<>(resultCollector.getCollectedCount());
    for (Message resultMessage = resultCollector.pollResult(); resultMessage != null; resultMessage = resultCollector.pollResult()) {
        // XEP-313 § 4.2
        MamResultExtension mamResultExtension = MamResultExtension.from(resultMessage);
        messages.add(mamResultExtension.getForwarded());
    }
    return new MamQueryResult(messages, mamFinExtension, DataForm.from(mamQueryIq));
}

0 个答案:

没有答案