function (reason)
    {
        this._changeConnectStatus(Strophe.Status.DISCONNECTING, reason);

        Strophe.info("Disconnect was called because: " + reason);
        if (this.connected) {
            var pres = false;
            this.disconnecting = true;
            if (this.authenticated) {
                pres = $pres({
                    xmlns: Strophe.NS.CLIENT,
                    type: 'unavailable'
                });
            }
            // setup timeout handler
            this._disconnectTimeout = this._addSysTimedHandler(
                3000, this._onDisconnectTimeout.bind(this));
            this._proto._disconnect(pres);
        } else {
            Strophe.info("Disconnect was called before Strophe connected to the server");
            this._proto._abortAllRequests();
        }
    }
function (reason)
    {
        this._changeConnectStatus(Strophe.Status.DISCONNECTING, reason);

        Strophe.info("Disconnect was called because: " + reason);
        if (this.connected) {
            var pres = false;
            this.disconnecting = true;
            if (this.authenticated) {
                pres = $pres({
                    xmlns: Strophe.NS.CLIENT,
                    type: 'unavailable'
                });
            }
            // setup timeout handler
            this._disconnectTimeout = this._addSysTimedHandler(
                3000, this._onDisconnectTimeout.bind(this));
            this._proto._disconnect(pres);
        } else {
            Strophe.info("Disconnect was called before Strophe connected to the server");
            this._proto._abortAllRequests();
        }
    }
function ( reason ) { this . _changeConnectStatus ( Strophe . Status . DISCONNECTING , reason ) ; Strophe . info ( "Disconnect was called because: " + reason ) ; if ( this . connected ) { var pres = false ; this . disconnecting = true ; if ( this . authenticated ) { pres = $pres ( { xmlns : Strophe . NS . CLIENT , type : 'unavailable' } ) ; } // setup timeout handler
 this . _disconnectTimeout = this . _addSysTimedHandler ( 3000 , this . _onDisconnectTimeout . bind ( this ) ) ; this . _proto . _disconnect ( pres ) ; } else { Strophe . info ( "Disconnect was called before Strophe connected to the server" ) ; this . _proto . _abortAllRequests ( ) ; } }
Function: disconnect
Start the graceful disconnection process.

This function starts the disconnection process.  This process starts
by sending unavailable presence and sending BOSH body of type
terminate.  A timeout handler makes sure that disconnection happens
even if the BOSH server does not respond.
If the Connection object isn't connected, at least tries to abort all pending requests
so the connection object won't generate successful requests (which were already opened).

The user supplied connection callback will be notified of the
progress as this process happens.

Parameters:
(String) reason - The reason the disconnect is occuring.
Function : disconnect Start the graceful disconnection process .
Disconnects from the server