Search in sources :

Example 1 with IQReplyFilter

use of org.jivesoftware.smack.filter.IQReplyFilter in project Smack by igniterealtime.

the class AbstractXMPPConnection method sendIqWithResponseCallback.

@Override
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException, InterruptedException {
    StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
    sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout);
}
Also used : StanzaFilter(org.jivesoftware.smack.filter.StanzaFilter) IQReplyFilter(org.jivesoftware.smack.filter.IQReplyFilter)

Example 2 with IQReplyFilter

use of org.jivesoftware.smack.filter.IQReplyFilter in project Smack by igniterealtime.

the class AbstractXMPPConnection method createStanzaCollectorAndSend.

@Override
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
    StanzaFilter packetFilter = new IQReplyFilter(packet, this);
    // Create the packet collector before sending the packet
    StanzaCollector packetCollector = createStanzaCollectorAndSend(packetFilter, packet);
    return packetCollector;
}
Also used : StanzaFilter(org.jivesoftware.smack.filter.StanzaFilter) IQReplyFilter(org.jivesoftware.smack.filter.IQReplyFilter)

Example 3 with IQReplyFilter

use of org.jivesoftware.smack.filter.IQReplyFilter in project Smack by igniterealtime.

the class MultiUserChatLightManager method getBlockingList.

private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
    MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
    mucLightBlockingIQ.setType(IQ.Type.get);
    mucLightBlockingIQ.setTo(mucLightService);
    StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection());
    IQ responseIq = connection().createStanzaCollectorAndSend(responseFilter, mucLightBlockingIQ).nextResultOrThrow();
    MUCLightBlockingIQ mucLightBlockingIQResult = (MUCLightBlockingIQ) responseIq;
    return mucLightBlockingIQResult;
}
Also used : StanzaFilter(org.jivesoftware.smack.filter.StanzaFilter) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) IQReplyFilter(org.jivesoftware.smack.filter.IQReplyFilter) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) IQ(org.jivesoftware.smack.packet.IQ)

Example 4 with IQReplyFilter

use of org.jivesoftware.smack.filter.IQReplyFilter in project Smack by igniterealtime.

the class MamManager method queryArchivePage.

private MamQueryPage queryArchivePage(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException {
    final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
    MamFinIQ mamFinIQ;
    StanzaCollector mamFinIQCollector = connection.createStanzaCollector(new IQReplyFilter(mamQueryIq, connection));
    StanzaCollector.Configuration resultCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter(new MamResultFilter(mamQueryIq)).setCollectorToReset(mamFinIQCollector);
    StanzaCollector cancelledResultCollector;
    try (StanzaCollector resultCollector = connection.createStanzaCollector(resultCollectorConfiguration)) {
        connection.sendStanza(mamQueryIq);
        mamFinIQ = mamFinIQCollector.nextResultOrThrow();
        cancelledResultCollector = resultCollector;
    }
    return new MamQueryPage(cancelledResultCollector, mamFinIQ);
}
Also used : IQReplyFilter(org.jivesoftware.smack.filter.IQReplyFilter) MamFinIQ(org.jivesoftware.smackx.mam.element.MamFinIQ) MamResultFilter(org.jivesoftware.smackx.mam.filter.MamResultFilter) XMPPConnection(org.jivesoftware.smack.XMPPConnection) StanzaCollector(org.jivesoftware.smack.StanzaCollector)

Example 5 with IQReplyFilter

use of org.jivesoftware.smack.filter.IQReplyFilter in project Smack by igniterealtime.

the class MamManager method queryArchive.

private MamQueryResult queryArchive(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException {
    final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
    MamFinIQ mamFinIQ = null;
    StanzaCollector mamFinIQCollector = connection.createStanzaCollector(new IQReplyFilter(mamQueryIq, connection));
    StanzaCollector.Configuration resultCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter(new MamResultFilter(mamQueryIq)).setCollectorToReset(mamFinIQCollector);
    StanzaCollector resultCollector = connection.createStanzaCollector(resultCollectorConfiguration);
    try {
        connection.sendStanza(mamQueryIq);
        mamFinIQ = mamFinIQCollector.nextResultOrThrow();
    } finally {
        mamFinIQCollector.cancel();
        resultCollector.cancel();
    }
    List<Forwarded> forwardedMessages = new ArrayList<>(resultCollector.getCollectedCount());
    for (Message resultMessage = resultCollector.pollResult(); resultMessage != null; resultMessage = resultCollector.pollResult()) {
        MamElements.MamResultExtension mamResultExtension = MamElements.MamResultExtension.from(resultMessage);
        forwardedMessages.add(mamResultExtension.getForwarded());
    }
    return new MamQueryResult(forwardedMessages, mamFinIQ, mamQueryIq.getNode(), DataForm.from(mamQueryIq));
}
Also used : Message(org.jivesoftware.smack.packet.Message) IQReplyFilter(org.jivesoftware.smack.filter.IQReplyFilter) ArrayList(java.util.ArrayList) XMPPConnection(org.jivesoftware.smack.XMPPConnection) MamElements(org.jivesoftware.smackx.mam.element.MamElements) MamFinIQ(org.jivesoftware.smackx.mam.element.MamFinIQ) Forwarded(org.jivesoftware.smackx.forward.packet.Forwarded) MamResultFilter(org.jivesoftware.smackx.mam.filter.MamResultFilter) StanzaCollector(org.jivesoftware.smack.StanzaCollector)

Aggregations

IQReplyFilter (org.jivesoftware.smack.filter.IQReplyFilter)9 XMPPConnection (org.jivesoftware.smack.XMPPConnection)3 StanzaFilter (org.jivesoftware.smack.filter.StanzaFilter)3 HashMap (java.util.HashMap)2 StanzaCollector (org.jivesoftware.smack.StanzaCollector)2 IQ (org.jivesoftware.smack.packet.IQ)2 Registration (org.jivesoftware.smackx.iqregister.packet.Registration)2 MamFinIQ (org.jivesoftware.smackx.mam.element.MamFinIQ)2 MamResultFilter (org.jivesoftware.smackx.mam.filter.MamResultFilter)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 SmackException (org.jivesoftware.smack.SmackException)1 Message (org.jivesoftware.smack.packet.Message)1 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)1 Version (org.jivesoftware.smackx.iqversion.packet.Version)1 MamElements (org.jivesoftware.smackx.mam.element.MamElements)1 MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)1 Time (org.jivesoftware.smackx.time.packet.Time)1