close(reconnect) {
        this.autoReconnect = reconnect;
        if (this.pingTimeout) {
            clearTimeout(this.pingTimeout);
            this.pingTimeout = null;
        }
        if (this.pingWaitTimeout) {
            clearTimeout(this.pingWaitTimeout);
            this.pingWaitTimeout = null;
        }
        Object.keys(this.expectedResponsePromises).forEach(res => {
            clearTimeout(this.expectedResponsePromises[res].responseTimeout);
            this.expectedResponsePromises[res].responsePromise.reject();
        });
        this.expectedResponsePromises = {};
        return new Promise(resolve => {
            if (this.socket) {
                debug('Destroy socket');
                this.socket.destroy();
                this.socket = null;
            }
            resolve(true);
        });
    }
/**
     * Closes the connection to the device and allows to define if an automatic reconnect should happen or not
     * @param {boolean} reconnect true to do an automatic reconnect, false if not
     *
     * @returns {Promise<boolean>} Resolves with true when connection is closed
     */
Closes the connection to the device and allows to define if an automatic reconnect should happen or not
@param {boolean} reconnect true to do an automatic reconnect, false if not

@returns {Promise} Resolves with true when connection is closed
Closes the connection to the device and allows to define if an automatic reconnect should happen or not @param { boolean } reconnect true to do an automatic reconnect false if not @returns { Promise } Resolves with true when connection is closed
close(reconnect) {
        this.autoReconnect = reconnect;
        if (this.pingTimeout) {
            clearTimeout(this.pingTimeout);
            this.pingTimeout = null;
        }
        if (this.pingWaitTimeout) {
            clearTimeout(this.pingWaitTimeout);
            this.pingWaitTimeout = null;
        }
        Object.keys(this.expectedResponsePromises).forEach(res => {
            clearTimeout(this.expectedResponsePromises[res].responseTimeout);
            this.expectedResponsePromises[res].responsePromise.reject();
        });
        this.expectedResponsePromises = {};
        return new Promise(resolve => {
            if (this.socket) {
                debug('Destroy socket');
                this.socket.destroy();
                this.socket = null;
            }
            resolve(true);
        });
    }
close ( reconnect ) { this . autoReconnect = reconnect ; if ( this . pingTimeout ) { clearTimeout ( this . pingTimeout ) ; this . pingTimeout = null ; } if ( this . pingWaitTimeout ) { clearTimeout ( this . pingWaitTimeout ) ; this . pingWaitTimeout = null ; } Object . keys ( this . expectedResponsePromises ) . forEach ( res => { clearTimeout ( this . expectedResponsePromises [ res ] . responseTimeout ) ; this . expectedResponsePromises [ res ] . responsePromise . reject ( ) ; } ) ; this . expectedResponsePromises = { } ; return new Promise ( resolve => { if ( this . socket ) { debug ( 'Destroy socket' ) ; this . socket . destroy ( ) ; this . socket = null ; } resolve ( true ) ; } ) ; }
Closes the connection to the device and allows to define if an automatic reconnect should happen or not
 @param {boolean} reconnect true to do an automatic reconnect, false if not
Closes the connection to the device and allows to define if an automatic reconnect should happen or not @param { boolean } reconnect true to do an automatic reconnect false if not