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);
}
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;
}
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;
}
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);
}
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));
}
Aggregations