src/main/java/org/jivesoftware/smack/XMPPConnection.java
protected void shutdown(Presence unavailablePresence) {
        // Set presence to offline.
        if (packetWriter != null) {
            packetWriter.sendPacket(unavailablePresence);
        }

        this.setWasAuthenticated(authenticated);
        authenticated = false;

        if (packetReader != null) {
            packetReader.shutdown();
        }
        if (packetWriter != null) {
            packetWriter.shutdown();
        }

        // Wait 150 ms for processes to clean-up, then shutdown.
        try {
            Thread.sleep(150);
        } catch (Exception e) {
            // Ignore.
        }

        // Set socketClosed to true. This will cause the PacketReader
        // and PacketWriter to ignore any Exceptions that are thrown
        // because of a read/write from/to a closed stream.
        // It is *important* that this is done before socket.close()!
        socketClosed = true;
        try {
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        for (Plugin plugin : plugins) {
			plugin.shutdown();
		}
        
        // In most cases the close() should be successful, so set
        // connected to false here.
        connected = false;

        reader = null;
        writer = null;

        saslAuthentication.init();
    }
protected void shutdown(Presence unavailablePresence) {
        // Set presence to offline.
        if (packetWriter != null) {
            packetWriter.sendPacket(unavailablePresence);
        }

        this.setWasAuthenticated(authenticated);
        authenticated = false;

        if (packetReader != null) {
            packetReader.shutdown();
        }
        if (packetWriter != null) {
            packetWriter.shutdown();
        }

        // Wait 150 ms for processes to clean-up, then shutdown.
        try {
            Thread.sleep(150);
        } catch (Exception e) {
            // Ignore.
        }

        // Set socketClosed to true. This will cause the PacketReader
        // and PacketWriter to ignore any Exceptions that are thrown
        // because of a read/write from/to a closed stream.
        // It is *important* that this is done before socket.close()!
        socketClosed = true;
        try {
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        for (Plugin plugin : plugins) {
			plugin.shutdown();
		}
        
        // In most cases the close() should be successful, so set
        // connected to false here.
        connected = false;

        reader = null;
        writer = null;

        saslAuthentication.init();
    }
protected void shutdown ( Presence unavailablePresence ) { // Set presence to offline. if ( packetWriter != null ) { packetWriter . sendPacket ( unavailablePresence ) ; } this . setWasAuthenticated ( authenticated ) ; authenticated = false ; if ( packetReader != null ) { packetReader . shutdown ( ) ; } if ( packetWriter != null ) { packetWriter . shutdown ( ) ; } // Wait 150 ms for processes to clean-up, then shutdown. try { Thread . sleep ( 150 ) ; } catch ( Exception e ) { // Ignore. } // Set socketClosed to true. This will cause the PacketReader // and PacketWriter to ignore any Exceptions that are thrown // because of a read/write from/to a closed stream. // It is *important* that this is done before socket.close()! socketClosed = true ; try { socket . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } for ( Plugin plugin : plugins ) { plugin . shutdown ( ) ; } // In most cases the close() should be successful, so set // connected to false here. connected = false ; reader = null ; writer = null ; saslAuthentication . init ( ) ; }
Closes the connection by setting presence to unavailable then closing the
stream to the XMPP server. The shutdown logic will be used during a
planned disconnection or when dealing with an unexpected disconnection.
Unlike {@link #disconnect()} the connection's packet reader, packet
writer, and {@link UserRoster} will not be removed; thus connection's
state is kept.

@param unavailablePresence
the presence packet to send during shutdown.
Closes the connection by setting presence to unavailable then closing the stream to the XMPP server . The shutdown logic will be used during a planned disconnection or when dealing with an unexpected disconnection . Unlike { @link #disconnect () } the connection s packet reader packet writer and { @link UserRoster } will not be removed ; thus connection s state is kept .