本文整理匯總了Java中org.jivesoftware.smack.sm.StreamManagementException類的典型用法代碼示例。如果您正苦於以下問題:Java StreamManagementException類的具體用法?Java StreamManagementException怎麽用?Java StreamManagementException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StreamManagementException類屬於org.jivesoftware.smack.sm包,在下文中一共展示了StreamManagementException類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addStanzaIdAcknowledgedListener
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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);
}
示例2: addStanzaIdAcknowledgedListener
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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);
}
示例3: requestSmAcknowledgement
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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();
}
示例4: sendMessage
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
boolean sendMessage(org.jivesoftware.smack.packet.Message message, long databaseId) {
final KontalkConnection conn = mConnection;
if (conn != null) {
if (databaseId > 0) {
// set up an ack listener so we can set message status to sent
try {
conn.addStanzaIdAcknowledgedListener(message.getStanzaId(),
new MessageAckListener(this, databaseId));
}
catch (StreamManagementException.StreamManagementNotEnabledException e) {
return false;
}
// matching release is in SM ack listener
mIdleHandler.hold(false);
mWaitingReceipt.add(databaseId);
}
boolean sent = sendPacket(message);
if (!sent && databaseId > 0) {
// message was not sent, remove from waiting queue
mWaitingReceipt.remove(databaseId);
mIdleHandler.release();
}
return sent;
}
return false;
}
示例5: XMPPTCPConnection
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* Creates a new XMPP connection over TCP (optionally using proxies).
* <p>
* Note that XMPPTCPConnection constructors do not establish a connection to the server
* and you must call {@link #connect()}.
* </p>
*
* @param config the connection configuration.
*/
public XMPPTCPConnection(XMPPTCPConnectionConfiguration config) {
super(config);
this.config = config;
addConnectionListener(new AbstractConnectionListener() {
@Override
public void connectionClosedOnError(Exception e) {
if (e instanceof XMPPException.StreamErrorException || e instanceof StreamManagementException) {
dropSmState();
}
}
});
}
示例6: sendSmAcknowledgement
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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();
}
示例7: requestSmAcknowledgement
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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();
}
示例8: sendSmAcknowledgement
import org.jivesoftware.smack.sm.StreamManagementException; //導入依賴的package包/類
/**
* 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();
}