@@ -22,22 +22,22 @@ const mqtt = require('mqtt');
2222// [END iot_mqtt_include]
2323
2424// The initial backoff time after a disconnection occurs, in seconds.
25- var MINIMUM_BACKOFF_TIME = 1 ;
25+ const MINIMUM_BACKOFF_TIME = 1 ;
2626
2727// The maximum backoff time before giving up, in seconds.
28- var MAXIMUM_BACKOFF_TIME = 32 ;
28+ const MAXIMUM_BACKOFF_TIME = 32 ;
2929
3030// Whether to wait with exponential backoff before publishing.
31- var shouldBackoff = false ;
31+ let shouldBackoff = false ;
3232
3333// The current backoff time.
34- var backoffTime = 1 ;
34+ let backoffTime = 1 ;
3535
3636// Whether an asynchronous publish chain is in progress.
37- var publishChainInProgress = false ;
37+ let publishChainInProgress = false ;
3838
3939console . log ( 'Google Cloud IoT Core MQTT example.' ) ;
40- var argv = require ( `yargs` )
40+ const argv = require ( `yargs` )
4141 . options ( {
4242 projectId : {
4343 default : process . env . GCLOUD_PROJECT || process . env . GOOGLE_CLOUD_PROJECT ,
@@ -285,7 +285,7 @@ function publishAsync(
285285
286286 // Publish and schedule the next publish.
287287 publishChainInProgress = true ;
288- var publishDelayMs = 0 ;
288+ let publishDelayMs = 0 ;
289289 if ( shouldBackoff ) {
290290 publishDelayMs = 1000 * ( backoffTime + Math . random ( ) ) ;
291291 backoffTime *= 2 ;
@@ -307,7 +307,7 @@ function publishAsync(
307307 }
308308 } ) ;
309309
310- var schedulePublishDelayMs = argv . messageType === 'events' ? 1000 : 2000 ;
310+ const schedulePublishDelayMs = argv . messageType === 'events' ? 1000 : 2000 ;
311311 setTimeout ( function ( ) {
312312 // [START iot_mqtt_jwt_refresh]
313313 const secsFromIssue = parseInt ( Date . now ( ) / 1000 ) - iatTime ;
@@ -551,7 +551,7 @@ function publishAsyncGateway(
551551
552552 // Publish and schedule the next publish.
553553 publishChainInProgress = true ;
554- var publishDelayMs = 0 ;
554+ let publishDelayMs = 0 ;
555555 if ( shouldBackoff ) {
556556 publishDelayMs = 1000 * ( backoffTime + Math . random ( ) ) ;
557557 backoffTime *= 2 ;
@@ -576,7 +576,7 @@ function publishAsyncGateway(
576576 }
577577 } ) ;
578578
579- var schedulePublishDelayMs = 5000 ; // messageType === 'events' ? 1000 : 2000;
579+ const schedulePublishDelayMs = 5000 ; // messageType === 'events' ? 1000 : 2000;
580580 setTimeout ( function ( ) {
581581 const secsFromIssue = parseInt ( Date . now ( ) / 1000 ) - iatTime ;
582582 if ( secsFromIssue > tokenExpMins * 60 ) {
0 commit comments