mqlight.js
function(client) {
  if (typeof client === 'undefined'/* || client.constructor !== Client*/) {
    logger.entry('Client.reconnect', logger.NO_CLIENT_ID);
    logger.log('parms', logger.NO_CLIENT_ID, 'client:', client);
    logger.exit('Client.reconnect', logger.NO_CLIENT_ID, undefined);
    return;
  }
  logger.entry('Client.reconnect', client.id);
  if (client.state !== STATE_STARTED) {
    if (client.isStopped()) {
      logger.exit('Client.reconnect', client.id, null);
      return;
    } else if (client.state === STATE_RETRYING) {
      logger.exit('Client.reconnect', client.id, client);
      return client;
    }
  }
  client._setState(STATE_RETRYING);

  setImmediate(function() {
    // stop the messenger to free the object then attempt a reconnect
    stopMessenger(client, function(client) {
      logger.entry('Client.reconnect.stopProcessing', client.id);

      // clear the subscriptions list, if the cause of the reconnect happens
      // during check for messages we need a 0 length so it will check once
      // reconnected.
      logger.log('data', client.id, 'client._subscriptions:',
              client._subscriptions);
      while (client._subscriptions.length > 0) {
        client._queuedSubscriptions.push(client._subscriptions.shift());
      }
      // also clear any left over outstanding sends
      while (client._outstandingSends.length > 0) {
        client._outstandingSends.shift();
      }
      client._queuedStartCallbacks.push({
        callback: processQueuedActions,
        create: false
      });
      process.nextTick(function() {
        client._performConnect(false, true);
      });

      logger.exit('Client.reconnect.stopProcessing', client.id, null);
    });
  });

  logger.exit('Client.reconnect', client.id, client);
  return client;
}
function(client) {
  if (typeof client === 'undefined'/* || client.constructor !== Client*/) {
    logger.entry('Client.reconnect', logger.NO_CLIENT_ID);
    logger.log('parms', logger.NO_CLIENT_ID, 'client:', client);
    logger.exit('Client.reconnect', logger.NO_CLIENT_ID, undefined);
    return;
  }
  logger.entry('Client.reconnect', client.id);
  if (client.state !== STATE_STARTED) {
    if (client.isStopped()) {
      logger.exit('Client.reconnect', client.id, null);
      return;
    } else if (client.state === STATE_RETRYING) {
      logger.exit('Client.reconnect', client.id, client);
      return client;
    }
  }
  client._setState(STATE_RETRYING);

  setImmediate(function() {
    // stop the messenger to free the object then attempt a reconnect
    stopMessenger(client, function(client) {
      logger.entry('Client.reconnect.stopProcessing', client.id);

      // clear the subscriptions list, if the cause of the reconnect happens
      // during check for messages we need a 0 length so it will check once
      // reconnected.
      logger.log('data', client.id, 'client._subscriptions:',
              client._subscriptions);
      while (client._subscriptions.length > 0) {
        client._queuedSubscriptions.push(client._subscriptions.shift());
      }
      // also clear any left over outstanding sends
      while (client._outstandingSends.length > 0) {
        client._outstandingSends.shift();
      }
      client._queuedStartCallbacks.push({
        callback: processQueuedActions,
        create: false
      });
      process.nextTick(function() {
        client._performConnect(false, true);
      });

      logger.exit('Client.reconnect.stopProcessing', client.id, null);
    });
  });

  logger.exit('Client.reconnect', client.id, client);
  return client;
}
function ( client ) { if ( typeof client === 'undefined' /* || client.constructor !== Client*/ ) { logger . entry ( 'Client.reconnect' , logger . NO_CLIENT_ID ) ; logger . log ( 'parms' , logger . NO_CLIENT_ID , 'client:' , client ) ; logger . exit ( 'Client.reconnect' , logger . NO_CLIENT_ID , undefined ) ; return ; } logger . entry ( 'Client.reconnect' , client . id ) ; if ( client . state !== STATE_STARTED ) { if ( client . isStopped ( ) ) { logger . exit ( 'Client.reconnect' , client . id , null ) ; return ; } else if ( client . state === STATE_RETRYING ) { logger . exit ( 'Client.reconnect' , client . id , client ) ; return client ; } } client . _setState ( STATE_RETRYING ) ; setImmediate ( function ( ) { // stop the messenger to free the object then attempt a reconnect stopMessenger ( client , function ( client ) { logger . entry ( 'Client.reconnect.stopProcessing' , client . id ) ; // clear the subscriptions list, if the cause of the reconnect happens // during check for messages we need a 0 length so it will check once // reconnected. logger . log ( 'data' , client . id , 'client._subscriptions:' , client . _subscriptions ) ; while ( client . _subscriptions . length > 0 ) { client . _queuedSubscriptions . push ( client . _subscriptions . shift ( ) ) ; } // also clear any left over outstanding sends while ( client . _outstandingSends . length > 0 ) { client . _outstandingSends . shift ( ) ; } client . _queuedStartCallbacks . push ( { callback : processQueuedActions , create : false } ) ; process . nextTick ( function ( ) { client . _performConnect ( false , true ) ; } ) ; logger . exit ( 'Client.reconnect.stopProcessing' , client . id , null ) ; } ) ; } ) ; logger . exit ( 'Client.reconnect' , client . id , client ) ; return client ; }
Reconnects the client to the MQ Light service, implicitly closing any
subscriptions that the client has open. The 'restarted' event will be
emitted once the client has reconnected.

@param {client} client - the client object to reconnect
@return {Object} The instance of client that it is invoked on - allowing
for chaining of other method calls on the client object.
Reconnects the client to the MQ Light service implicitly closing any subscriptions that the client has open . The restarted event will be emitted once the client has reconnected .