lib/rtm-client.js
function() {
    var me = this;
    var connectionOptions = me._connectionOptions;

    return promised(function(cb) {
      if (me.isConnected || me.status === 'connecting') {
        return cb(new Error('Broker client already connected or connecting.'));
      }

      if (!me.mqttClient) {
        var mqttClient = new PahoMQTT.Client(
          connectionOptions.host,
          connectionOptions.port,
          connectionOptions.path,
          connectionOptions.clientId
        );

        _registerPahoClientEventListeners(me, mqttClient);
        me.mqttClient = mqttClient;
      }

      me.status = 'connecting';
      me.emit('connecting');

      me.mqttClient.connect(
        merge(_getPahoCallbacks(cb), {
          cleanSession: connectionOptions.clean,
          keepAliveInterval: connectionOptions.keepAliveInterval,
          reconnect: connectionOptions.reconnect,
          useSSL: connectionOptions.useSSL
        })
      );
    }).then(function(connectResponse) {
      if (me.enableSubscriptionSyncEvents) {
        me.initSubscriptionSyncEvents();
      }

      return connectResponse;
    });
  }
function() {
    var me = this;
    var connectionOptions = me._connectionOptions;

    return promised(function(cb) {
      if (me.isConnected || me.status === 'connecting') {
        return cb(new Error('Broker client already connected or connecting.'));
      }

      if (!me.mqttClient) {
        var mqttClient = new PahoMQTT.Client(
          connectionOptions.host,
          connectionOptions.port,
          connectionOptions.path,
          connectionOptions.clientId
        );

        _registerPahoClientEventListeners(me, mqttClient);
        me.mqttClient = mqttClient;
      }

      me.status = 'connecting';
      me.emit('connecting');

      me.mqttClient.connect(
        merge(_getPahoCallbacks(cb), {
          cleanSession: connectionOptions.clean,
          keepAliveInterval: connectionOptions.keepAliveInterval,
          reconnect: connectionOptions.reconnect,
          useSSL: connectionOptions.useSSL
        })
      );
    }).then(function(connectResponse) {
      if (me.enableSubscriptionSyncEvents) {
        me.initSubscriptionSyncEvents();
      }

      return connectResponse;
    });
  }
function ( ) { var me = this ; var connectionOptions = me . _connectionOptions ; return promised ( function ( cb ) { if ( me . isConnected || me . status === 'connecting' ) { return cb ( new Error ( 'Broker client already connected or connecting.' ) ) ; } if ( ! me . mqttClient ) { var mqttClient = new PahoMQTT . Client ( connectionOptions . host , connectionOptions . port , connectionOptions . path , connectionOptions . clientId ) ; _registerPahoClientEventListeners ( me , mqttClient ) ; me . mqttClient = mqttClient ; } me . status = 'connecting' ; me . emit ( 'connecting' ) ; me . mqttClient . connect ( merge ( _getPahoCallbacks ( cb ) , { cleanSession : connectionOptions . clean , keepAliveInterval : connectionOptions . keepAliveInterval , reconnect : connectionOptions . reconnect , useSSL : connectionOptions . useSSL } ) ) ; } ) . then ( function ( connectResponse ) { if ( me . enableSubscriptionSyncEvents ) { me . initSubscriptionSyncEvents ( ) ; } return connectResponse ; } ) ; }
Opens a connection to the

@return {Promise}
Opens a connection to the