@Override public StanzaCollector createStanzaCollector(StanzaFilter packetFilter) { StanzaCollector.Configuration configuration = StanzaCollector.newConfiguration().setStanzaFilter(packetFilter); return createStanzaCollector(configuration); }
/** * Get the XMPPConnection of this Manager if it's authenticated, i.e. logged in. Otherwise throw a {@link NotLoggedInException}. * * @return the XMPPConnection of this Manager. * @throws NotLoggedInException if the connection is not authenticated. */ protected final XMPPConnection getAuthenticatedConnectionOrThrow() throws NotLoggedInException { XMPPConnection connection = connection(); if (!connection.isAuthenticated()) { throw new NotLoggedInException(); } return connection; }
protected void throwNotConnectedExceptionIfAppropriate(String optionalHint) throws NotConnectedException { if (!isConnected()) { throw new NotConnectedException(optionalHint); } }
/** * Returns true if the reconnection mechanism is enabled. * * @return true if automatic reconnection is allowed. */ private boolean isReconnectionPossible(XMPPConnection connection) { return !done && !connection.isConnected() && isAutomaticReconnectEnabled(); }
/** * 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()); }
/** * Remove the connection callbacks used by this MUC Light from the * connection. */ private void removeConnectionCallbacks() { connection.removeSyncStanzaListener(messageListener); if (messageCollector != null) { messageCollector.cancel(); messageCollector = null; } }
protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) { super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size)); } }
@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; }
protected void throwAlreadyConnectedExceptionIfAppropriate() throws AlreadyConnectedException { if (isConnected()) { throw new AlreadyConnectedException(); } }
public DummyConnection(ConnectionConfiguration configuration) { super(configuration); for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) { listener.connectionCreated(this); } user = getUserJid(); }
@Override public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException, NotLoggedInException { try { callback.processStanza(packet); } finally { removeSyncStanzaListener(this); } } };
protected void throwAlreadyLoggedInExceptionIfAppropriate() throws AlreadyLoggedInException { if (isAuthenticated()) { throw new AlreadyLoggedInException(); } }
public static NoResponseException newWith(XMPPConnection connection, StanzaCollector collector) { return newWith(connection, collector.getStanzaFilter()); }
public static ConnectionConfiguration.Builder<?,?> getDummyConfigurationBuilder() { return DummyConnectionConfiguration.builder().setXmppDomain(JidTestUtil.EXAMPLE_ORG).setUsernameAndPassword("dummy", "dummypass"); }
public B enableDefaultDebugger() { this.debuggerFactory = SmackConfiguration.getDefaultSmackDebuggerFactory(); assert this.debuggerFactory != null; return getThis(); }
@Override public CallbackRecipient<V, E> onError(ExceptionCallback<E> exceptionCallback) { this.exceptionCallback = exceptionCallback; maybeInvokeCallbacks(); return this; }
@Override public void run() { removeSyncStanzaListener(packetListener); } }, getReplyTimeout(), TimeUnit.MILLISECONDS);
/** * Set the XMPP domain. The XMPP domain is what follows after the '@' sign in XMPP addresses (JIDs). * * @param xmppDomain the XMPP domain. * @return a reference to this builder. */ public B setXmppDomain(DomainBareJid xmppDomain) { this.xmppServiceDomain = xmppDomain; return getThis(); }
private static DummyConnectionConfiguration.Builder newUnitTestBuilder() { DummyConnectionConfiguration.Builder builder = DummyConnectionConfiguration.builder(); builder.setXmppDomain(JidTestUtil.DOMAIN_BARE_JID_1); return builder; }
@Override public String toString() { return toXML(null); } }