@Override protected void throwAlreadyConnectedExceptionIfAppropriate() throws AlreadyConnectedException { if (isConnected() && !disconnectedButResumeable) { throw new AlreadyConnectedException(); } }
if (!connection.isConnected()) { try { connection.connect().login();
/*** BEGIN: Methods for the Manager ***/ private boolean isConnected() { return xmppConn != null ? xmppConn.isConnected() : false; }
@Override protected void onActivate() throws XMPPException, IOException, SmackException { if (!connection.isConnected()) { try { connection.connect(); } catch (InterruptedException e) { throw new IOException(e); } } }
public void disconnectGracefully() { logger.info("Disconnecting ..."); if (xmppConn.isConnected()) { logger.info("Disconnecting the xmpp server from FCM"); xmppConn.disconnect(); // this method call the onClosed listener because it have not been detached } }
@Override protected void onActivate() throws XMPPException, IOException, SmackException { if (!connection.isConnected()) { try { connection.connect(); } catch (InterruptedException e) { throw new IOException(e); } } }
@Override protected void onActivate() throws XMPPException, IOException, SmackException { if (!connection.isConnected()) { try { connection.connect(); } catch (InterruptedException e) { throw new IOException(e); } } }
/** * Check if manager is logged in to xmpp server. * * @return true if logged in, false otherwise */ private void login() { try { if (xmpp.isConnected()) { LOG.debug("XMPP Manager logging in"); xmpp.login(xmppUser, xmppPassword, XMPP_RESOURCE); rooms.clear(); } else { LOG.debug("XMPP Manager unable to login: Not connected to XMPP server"); } } catch (Throwable e) { LOG.error("XMPP Manager unable to login: ", e); } }
@Override protected void onShutdown() { if (logger.isInfoEnabled()) { logger.info("Shutting down XMPP receiver [" + connection.getUser() + "]"); } if (connection.isConnected()) { connection.disconnect(); } }
/** * 是否连接成功 * * @return */ public boolean isConnected() { if (connection == null) { return false; } if (!connection.isConnected()) { try { connection.connect(); return true; } catch (Exception e) { return false; } } return true; }
@Override protected void onShutdown() { if (logger.isInfoEnabled()) { logger.info("Shutting down XMPP receiver [" + connection.getUser() + "]"); } if (connection.isConnected()) { connection.disconnect(); } }
@Override protected void onShutdown() { if (logger.isInfoEnabled()) { logger.info("Shutting down XMPP receiver [" + connection.getUser() + "]"); } if (connection.isConnected()) { connection.disconnect(); } }
private void connectToServer() { try { LOG.debug("Attempting vanilla XMPP Connection to {}:{}", xmppServer, xmppPort); xmpp.connect(); if (xmpp.isConnected()) { LOG.debug("XMPP Manager successfully connected"); // Following requires a later version of the library if (xmpp.isSecureConnection()) LOG.debug("XMPP Manager successfully negotiated a secure connection"); if (xmpp.isUsingTLS()) LOG.debug("XMPP Manager successfully negotiated a TLS connection"); LOG.debug("XMPP Manager Connected"); login(); // Add connection listener xmpp.addConnectionListener(conlistener); } else { LOG.debug("XMPP Manager Not Connected"); } } catch (Throwable e) { LOG.error("XMPP Manager unable to connect", e); } }
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(); } }