private static StringBuilder getWaitingFor(XMPPConnection connection) { final long replyTimeout = connection.getReplyTimeout(); final StringBuilder sb = new StringBuilder(256); sb.append("No response received within reply timeout. Timeout was " + replyTimeout + "ms (~" + replyTimeout / 1000 + "s)."); return sb; } }
/** * Returns the next available packet. The method call will block until the connection's default * timeout has elapsed. * * @param <P> type of the result stanza. * @return the next available packet. * @throws InterruptedException */ public <P extends Stanza> P nextResult() throws InterruptedException { return nextResult(connection.getReplyTimeout()); }
/** * Get a new MUC enter configuration builder. * * @param nickname the nickname used when entering the MUC room. * @return a new MUC enter configuration builder. * @since 4.2 */ public MucEnterConfiguration.Builder getEnterConfigurationBuilder(Resourcepart nickname) { return new MucEnterConfiguration.Builder(nickname, connection.getReplyTimeout()); }
/** * Returns the next available stanza. The method in equivalent to * {@link #nextResultOrThrow(long)} where the timeout argument is the default reply timeout of * the connection associated with this collector. * * @param <P> type of the result stanza. * @return the next available stanza. * @throws XMPPErrorException in case an error response was received. * @throws NoResponseException if there was no response from the server. * @throws InterruptedException * @throws NotConnectedException * @see #nextResultOrThrow(long) */ public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { return nextResultOrThrow(connection.getReplyTimeout()); }
/** * Same as calling {@link #ping(Jid, long)} with the defaultpacket reply * timeout. * * @param jid The id of the entity the ping is being sent to * @return true if a reply was received from the entity, false otherwise. * @throws NotConnectedException * @throws NoResponseException if there was no response from the jid. * @throws InterruptedException */ public boolean ping(Jid jid) throws NotConnectedException, NoResponseException, InterruptedException { return ping(jid, connection().getReplyTimeout()); }
public SmackFuture<Boolean, Exception> pingAsync(Jid jid) { return pingAsync(jid, connection().getReplyTimeout()); }
/** * Pings the server. This method will return true if the server is reachable. It * is the equivalent of calling <code>ping</code> with the XMPP domain. * <p> * Unlike the {@link #ping(Jid)} case, this method will return true even if * {@link #isPingSupported(Jid)} is false. * * @param notifyListeners Notify the PingFailedListener in case of error if true * @return true if the user's server could be pinged. * @throws NotConnectedException * @throws InterruptedException */ public boolean pingMyServer(boolean notifyListeners) throws NotConnectedException, InterruptedException { return pingMyServer(notifyListeners, connection().getReplyTimeout()); }
protected boolean waitUntilLoaded() throws InterruptedException { long waitTime = connection().getReplyTimeout(); long start = System.currentTimeMillis(); while (!isLoaded()) { if (waitTime <= 0) { break; } synchronized (this) { if (!isLoaded()) { wait(waitTime); } } long now = System.currentTimeMillis(); waitTime -= now - start; start = now; } return isLoaded(); }
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; }
rosterOne.createEntry(conTwo.getUser().asBareJid(), conTwosRosterName, null); assertTrue(addedAndSubscribed.waitForResult(2 * connection.getReplyTimeout()));
private static StringBuilder getWaitingFor(XMPPConnection connection) { final long replyTimeout = connection.getReplyTimeout(); final StringBuilder sb = new StringBuilder(256); sb.append("No response received within reply timeout. Timeout was " + replyTimeout + "ms (~" + replyTimeout / 1000 + "s)."); return sb; } }
/** * Returns the next available packet. The method call will block until the connection's default * timeout has elapsed. * * @param <P> type of the result stanza. * @return the next available packet. * @throws InterruptedException */ public <P extends Stanza> P nextResult() throws InterruptedException { return nextResult(connection.getReplyTimeout()); }
/** * Returns the next available stanza. The method in equivalent to * {@link #nextResultOrThrow(long)} where the timeout argument is the default reply timeout of * the connection associated with this collector. * * @param <P> type of the result stanza. * @return the next available stanza. * @throws XMPPErrorException in case an error response was received. * @throws NoResponseException if there was no response from the server. * @throws InterruptedException * @throws NotConnectedException * @see #nextResultOrThrow(long) */ public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { return nextResultOrThrow(connection.getReplyTimeout()); }
protected boolean waitUntilLoaded() throws InterruptedException { long waitTime = connection().getReplyTimeout(); long start = System.currentTimeMillis(); while (!isLoaded()) { if (waitTime <= 0) { break; } synchronized (this) { if (!isLoaded()) { wait(waitTime); } } long now = System.currentTimeMillis(); waitTime -= now - start; start = now; } return isLoaded(); }