/** * Add a new Stanza ID acknowledged listener for the given ID. * <p> * The listener will be invoked if the stanza with the given ID was acknowledged by the server. It will * automatically be removed after the listener was run. * </p> * * @param id the stanza ID. * @param listener the listener to invoke. * @return the previous listener for this stanza ID or null. * @throws StreamManagementNotEnabledException if Stream Management is not enabled. */ public StanzaListener addStanzaIdAcknowledgedListener(final String id, StanzaListener listener) throws StreamManagementNotEnabledException { // Prevent users from adding callbacks that will never get removed if (!smWasEnabledAtLeastOnce) { throw new StreamManagementException.StreamManagementNotEnabledException(); } // Remove the listener after max. 12 hours final int removeAfterSeconds = Math.min(getMaxSmResumptionTime(), 12 * 60 * 60); schedule(new Runnable() { @Override public void run() { stanzaIdAcknowledgedListeners.remove(id); } }, removeAfterSeconds, TimeUnit.SECONDS); return stanzaIdAcknowledgedListeners.put(id, listener); }
/** * Send an unconditional Stream Management acknowledgement request to the server. * * @throws StreamManagementNotEnabledException if Stream Mangement is not enabled. * @throws NotConnectedException if the connection is not connected. */ public void requestSmAcknowledgement() throws StreamManagementNotEnabledException, NotConnectedException { if (!isSmEnabled()) { throw new StreamManagementException.StreamManagementNotEnabledException(); } requestSmAcknowledgementInternal(); }
/** Resumes outgoing ack packets and sends one right away. */ public void resumeSmAck() throws NotConnectedException, StreamManagementNotEnabledException, InterruptedException { synchronized (clientHandledStanzasCountLock) { if (smAckSuspend) { smAckSuspend = false; if (ackPending) { sendSmAcknowledgement(); ackPending = false; } } } }
/** * Send a unconditional Stream Management acknowledgment to the server. * <p> * See <a href="http://xmpp.org/extensions/xep-0198.html#acking">XEP-198: Stream Management § 4. Acks</a>: * "Either party MAY send an <a/> element at any time (e.g., after it has received a certain number of stanzas, * or after a certain period of time), even if it has not received an <r/> element from the other party." * </p> * * @throws StreamManagementNotEnabledException if Stream Management is not enabled. * @throws NotConnectedException if the connection is not connected. */ public void sendSmAcknowledgement() throws StreamManagementNotEnabledException, NotConnectedException { if (!isSmEnabled()) { throw new StreamManagementException.StreamManagementNotEnabledException(); } sendSmAcknowledgementInternal(); }
/** * Send an unconditional Stream Management acknowledgement request to the server. * * @throws StreamManagementNotEnabledException if Stream Mangement is not enabled. * @throws NotConnectedException if the connection is not connected. * @throws InterruptedException */ public void requestSmAcknowledgement() throws StreamManagementNotEnabledException, NotConnectedException, InterruptedException { if (!isSmEnabled()) { throw new StreamManagementException.StreamManagementNotEnabledException(); } requestSmAcknowledgementInternal(); }
/** * Send a unconditional Stream Management acknowledgment to the server. * <p> * See <a href="http://xmpp.org/extensions/xep-0198.html#acking">XEP-198: Stream Management § 4. Acks</a>: * "Either party MAY send an <a/> element at any time (e.g., after it has received a certain number of stanzas, * or after a certain period of time), even if it has not received an <r/> element from the other party." * </p> * * @throws StreamManagementNotEnabledException if Stream Management is not enabled. * @throws NotConnectedException if the connection is not connected. * @throws InterruptedException */ public void sendSmAcknowledgement() throws StreamManagementNotEnabledException, NotConnectedException, InterruptedException { if (!isSmEnabled()) { throw new StreamManagementException.StreamManagementNotEnabledException(); } sendSmAcknowledgementInternal(); }