mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +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);
|
||||
}
|
||||
|
||||
@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
|
||||
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
|
||||
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.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||
|
@ -191,6 +192,20 @@ public interface XMPPConnection {
|
|||
*/
|
||||
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>.
|
||||
* Does also send <code>packet</code>. The stanza(/packet) filter for the collector is an
|
||||
|
|
Loading…
Reference in a new issue