ReconnectionManager.getInstanceFor(abstractXmppConnection).addReconnectionListener(reconnectionListener); } else { LOGGER.info("The connection instance " + connection
/** * Get a instance of ReconnectionManager for the given connection. * * @param connection * @return a ReconnectionManager for the connection. */ public static synchronized ReconnectionManager getInstanceFor(AbstractXMPPConnection connection) { ReconnectionManager reconnectionManager = INSTANCES.get(connection); if (reconnectionManager == null) { reconnectionManager = new ReconnectionManager(connection); INSTANCES.put(connection, reconnectionManager); } return reconnectionManager; }
ReconnectionManager.getInstanceFor(xmppConn).enableAutomaticReconnection(); ReconnectionManager.getInstanceFor(xmppConn).addReconnectionListener(this);
sessionManager.setJID( connection.getUser() ); final ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor( connection ); reconnectionManager.setFixedDelay( localPref.getReconnectDelay() ); reconnectionManager.setReconnectionPolicy( ReconnectionManager.ReconnectionPolicy.FIXED_DELAY ); reconnectionManager.enableAutomaticReconnection();
.getInstanceFor(connection) .addReconnectionListener(reConnListener); = ReconnectionManager.getInstanceFor(connection); if (reconnectionManager != null) reconnectionManager.removeReconnectionListener(reConnListener);
ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(mConnection); if (!reconnectionManager.isAutomaticReconnectEnabled()) { reconnectionManager.enableAutomaticReconnection(); }
public void connectionClosedOnError(Exception e) { done = false; if (e instanceof XMPPException) { XMPPException xmppEx = (XMPPException) e; StreamError error = xmppEx.getStreamError(); // Make sure the error is not null if (error != null) { String reason = error.getCode(); if ("conflict".equals(reason)) { return; } } } if (this.isReconnectionAllowed()) { this.reconnect(); } }
remainingSeconds--; ReconnectionManager.this .notifyAttemptToReconnectIn(remainingSeconds); ReconnectionManager.this.notifyReconnectionFailed(e1); ReconnectionManager.this.notifyReconnectionFailed(e);
@Override public void connectionCreated(XMPPConnection connection) { if (connection instanceof AbstractXMPPConnection) { ReconnectionManager.getInstanceFor((AbstractXMPPConnection) connection); } } });
public void disconnectAll() { logger.info("Disconnecting all ..."); if (xmppConn.isConnected()) { logger.info("Detaching all the listeners for the connection."); PingManager.getInstanceFor(xmppConn).unregisterPingFailedListener(this); ReconnectionManager.getInstanceFor(xmppConn).removeReconnectionListener(this); xmppConn.removeAsyncStanzaListener(this); xmppConn.removeConnectionListener(this); xmppConn.removeStanzaInterceptor(this); xmppConn.removeAllRequestAckPredicates(); xmppConn.removeAllStanzaAcknowledgedListeners(); xmppConn.removeAllStanzaIdAcknowledgedListeners(); xmppConn.removeStanzaSendingListener(this); xmppConn.removeStanzaAcknowledgedListener(this); xmppConn.removeAllRequestAckPredicates(); logger.info("Disconnecting the xmpp server from FCM."); xmppConn.disconnect(); } }
/** * Fires listeners when a reconnection attempt has failed. * * @param exception the exception that occured. */ protected void notifyReconnectionFailed(Exception exception) { if (isReconnectionAllowed()) { for (ConnectionListener listener : connection.connectionListeners) { listener.reconnectionFailed(exception); } } }
connection.setPacketReplyTimeout(25000); ReconnectionManager manager = ReconnectionManager.getInstanceFor(connection); manager.setFixedDelay(15); ReconnectionManager.setDefaultReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY); manager.enableAutomaticReconnection(); try { connection.connect();
ReconnectionManager manager = ReconnectionManager.getInstanceFor(connection); manager.enableAutomaticReconnection();
/** * 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(); }
/** * Set the fixed delay in seconds between the reconnection attempts Also set the connection * policy to {@link ReconnectionPolicy#FIXED_DELAY}. * * @param fixedDelay Delay expressed in seconds */ public void setFixedDelay(int fixedDelay) { this.fixedDelay = fixedDelay; setReconnectionPolicy(ReconnectionPolicy.FIXED_DELAY); }
public void connectionClosedOnError(Exception e) { done = false; if (e instanceof XMPPException) { XMPPException xmppEx = (XMPPException) e; StreamError error = xmppEx.getStreamError(); // Make sure the error is not null if (error != null) { String reason = error.getCode(); if ("conflict".equals(reason)) { return; } } } if (this.isReconnectionAllowed()) { this.reconnect(); } }
remainingSeconds--; ReconnectionManager.this .notifyAttemptToReconnectIn(remainingSeconds); ReconnectionManager.this.notifyReconnectionFailed(e1); ReconnectionManager.this.notifyReconnectionFailed(e);
@Override public void connectionCreated(XMPPConnection connection) { if (connection instanceof AbstractXMPPConnection) { ReconnectionManager.getInstanceFor((AbstractXMPPConnection) connection); } } });
/** * Fires listeners when The Connection will retry a reconnection. Expressed in seconds. * * @param seconds the number of seconds that a reconnection will be attempted in. */ protected void notifyAttemptToReconnectIn(int seconds) { if (isReconnectionAllowed()) { for (ConnectionListener listener : connection.connectionListeners) { listener.reconnectingIn(seconds); } } }