/** * Check for a response and throw a {@link NoResponseException} if there was none. * <p> * The exception is thrown, if state is one of 'Initial', 'NoResponse' or 'RequestSent' * </p> * @return <code>true</code> if synchronization point was successful, <code>false</code> on failure. * @throws NoResponseException */ private E checkForResponse() throws NoResponseException { switch (state) { case Initial: case NoResponse: case RequestSent: throw NoResponseException.newWith(connection, waitFor); case Success: return null; case Failure: return failureException; default: throw new AssertionError("Unknown state " + state); } }
throw NoResponseException.newWith(connection, "successful SASL authentication");
protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException { final StreamInitiation response = createInitiationAccept(initiation, getNamespaces()); newStreamInitiation(initiation.getFrom(), initiation.getSessionID()); final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID(); IQ streamMethodInitiation; try { streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() { @Override public void action() throws NotConnectedException { try { connection.sendStanza(response); } catch (InterruptedException e) { // Ignore } } }); } catch (InterruptedException e) { // TODO remove this try/catch once merged into 4.2's master branch throw new IllegalStateException(e); } if (streamMethodInitiation == null) { throw NoResponseException.newWith(connection, "stream initiation"); } XMPPErrorException.ifHasErrorThenThrow(streamMethodInitiation); return streamMethodInitiation; }
throw NoResponseException.newWith(connection, "successful SASL authentication");
throw new NotConnectedException(connection, packetFilter); throw NoResponseException.newWith(connection, this);
@Override public void run() { boolean removed = removeAsyncStanzaListener(packetListener); // If the packetListener got removed, then it was never run and // we never received a response, inform the exception callback if (removed && exceptionCallback != null) { Exception exception; if (!isConnected()) { // If the connection is no longer connected, throw a not connected exception. exception = new NotConnectedException(AbstractXMPPConnection.this, replyFilter); } else { exception = NoResponseException.newWith(AbstractXMPPConnection.this, replyFilter); } final Exception exceptionToProcess = exception; Async.go(new Runnable() { @Override public void run() { exceptionCallback.processException(exceptionToProcess); } }); } } }, timeout, TimeUnit.MILLISECONDS);
/** * Returns the latest version of Spark available via Spark Manager or Jive Software. * * @param connection the XMPPConnection to use. * @return the information for about the latest Spark Client. * @throws InterruptedException * @throws XMPPException If unable to retrieve latest version. */ public static SparkVersion getLatestVersion(XMPPConnection connection) throws SmackException, XMPPException.XMPPErrorException, InterruptedException { SparkVersion request = new SparkVersion(); request.setType(IQ.Type.get); request.setTo("updater." + connection.getXMPPServiceDomain()); // TODO: This should not use stanza collectors but simply createStanzaCollectorAndSend(IQ).nextResultOrThrow(); StanzaCollector collector = connection.createStanzaCollector(new IQReplyFilter( request, connection )); connection.sendStanza(request); SparkVersion response; try { response = collector.nextResult(); } finally { // Cancel the collector. collector.cancel(); } if (response == null) { throw SmackException.NoResponseException.newWith( connection, collector ); } XMPPException.XMPPErrorException.ifHasErrorThenThrow( response ); return response; }
@Override public void run() { boolean removed = removeAsyncStanzaListener(stanzaListener); if (!removed) { // We lost a race against the stanza listener, he already removed itself because he received a // reply. There is nothing more to do here. return; } // If the packetListener got removed, then it was never run and // we never received a response, inform the exception callback Exception exception; if (!isConnected()) { // If the connection is no longer connected, throw a not connected exception. exception = new NotConnectedException(AbstractXMPPConnection.this, replyFilter); } else { exception = NoResponseException.newWith(AbstractXMPPConnection.this, replyFilter); } future.setException(exception); } }, timeout, TimeUnit.MILLISECONDS);
/** * Check for a response and throw a {@link NoResponseException} if there was none. * <p> * The exception is thrown, if state is one of 'Initial', 'NoResponse' or 'RequestSent' * </p> * @return <code>true</code> if synchronization point was successful, <code>false</code> on failure. * @throws NoResponseException */ private E checkForResponse() throws NoResponseException { switch (state) { case Initial: case NoResponse: case RequestSent: throw NoResponseException.newWith(connection, waitFor); case Success: return null; case Failure: return failureException; default: throw new AssertionError("Unknown state " + state); } }
public static NoResponseException newWith(XMPPConnection connection, StanzaCollector collector) { return newWith(connection, collector.getStanzaFilter()); }
private Stanza getNextStanzaSkipContinues(StanzaCollector collector, long replyTimeout, XMPPTCPConnection authConnection) throws InterruptedException, NoResponseException, XMPPErrorException { while (true) { Stanza reply = collector.nextResult(replyTimeout); if (reply == null) { throw NoResponseException.newWith(authConnection, collector); } if (reply instanceof OAStanza && ((OAStanza) reply).isContinuePacket()) { continue; } return reply; } }
throw new NotConnectedException(connection, packetFilter); throw NoResponseException.newWith(connection, this);
@Override public void run() { boolean removed = removeAsyncStanzaListener(stanzaListener); if (!removed) { // We lost a race against the stanza listener, he already removed itself because he received a // reply. There is nothing more to do here. return; } // If the packetListener got removed, then it was never run and // we never received a response, inform the exception callback Exception exception; if (!isConnected()) { // If the connection is no longer connected, throw a not connected exception. exception = new NotConnectedException(AbstractXMPPConnection.this, replyFilter); } else { exception = NoResponseException.newWith(AbstractXMPPConnection.this, replyFilter); } future.setException(exception); } }, timeout, TimeUnit.MILLISECONDS);
public static NoResponseException newWith(XMPPConnection connection, StanzaCollector collector) { return newWith(connection, collector.getStanzaFilter()); }