mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Add XMPPConnection.sendIqRequestAndWaitForResponse(IQ)
This commit is contained in:
parent
a9ca1a0989
commit
1d12be1644
2 changed files with 25 additions and 0 deletions
|
@ -754,6 +754,16 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
connectionListeners.remove(connectionListener);
|
connectionListeners.remove(connectionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
||||||
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
|
StanzaCollector collector = createStanzaCollectorAndSend(request);
|
||||||
|
IQ resultResponse = collector.nextResultOrThrow();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
I concreteResultResponse = (I) resultResponse;
|
||||||
|
return concreteResultResponse;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
|
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
|
||||||
StanzaFilter packetFilter = new IQReplyFilter(packet, this);
|
StanzaFilter packetFilter = new IQReplyFilter(packet, this);
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smack;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.filter.IQReplyFilter;
|
import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||||
|
@ -191,6 +192,20 @@ public interface XMPPConnection {
|
||||||
*/
|
*/
|
||||||
void removeConnectionListener(ConnectionListener connectionListener);
|
void removeConnectionListener(ConnectionListener connectionListener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an IQ request and wait for the response.
|
||||||
|
*
|
||||||
|
* @param request the IQ request
|
||||||
|
* @return an IQ with type 'result'
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @throws XMPPErrorException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @since 4.3
|
||||||
|
*/
|
||||||
|
<I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
||||||
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new stanza(/packet) collector collecting packets that are replies to <code>packet</code>.
|
* Creates a new stanza(/packet) collector collecting packets that are replies to <code>packet</code>.
|
||||||
* Does also send <code>packet</code>. The stanza(/packet) filter for the collector is an
|
* Does also send <code>packet</code>. The stanza(/packet) filter for the collector is an
|
||||||
|
|
Loading…
Reference in a new issue