Updated simulator logs
This commit is contained in:
54
src/asset.js
54
src/asset.js
@ -57,7 +57,7 @@ class Asset {
|
||||
this.apiEndpoint = apiConfig.use_secure ? 'https' : 'http';
|
||||
this.apiEndpoint += '://' + apiConfig.host + (apiConfig.port ? (':' + apiConfig.port) : '');
|
||||
|
||||
this.soundPath = currentPath
|
||||
this.soundPath = currentPath;
|
||||
// this.soundPath += '/sounds/sound.mp3';
|
||||
this.soundPath += '/sounds/' + this.configs.sounds['sound'];
|
||||
// if (this.configs.sounds['custom' + this.id]) {
|
||||
@ -72,7 +72,7 @@ class Asset {
|
||||
}
|
||||
|
||||
_getDataFromApi(callback) {
|
||||
utils.writeLog(`Get informations about asset ${this.id}`)
|
||||
utils.writeLog(`Get informations about asset ${this.id}`);
|
||||
Request.get(
|
||||
this.apiEndpoint + '/asset/' + this.id,
|
||||
{
|
||||
@ -202,10 +202,10 @@ class Asset {
|
||||
utils.writeErrorLog(`ERROR_MURMUR`);
|
||||
return callback(err);
|
||||
} else {
|
||||
return callback();
|
||||
// setTimeout(()=> {
|
||||
// return callback();
|
||||
// }, 1000);
|
||||
// return callback();
|
||||
setTimeout(()=> {
|
||||
return callback();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -219,6 +219,10 @@ class Asset {
|
||||
}
|
||||
},
|
||||
(error, response, body) => {
|
||||
utils.writeLog(`_register ERROR --- ${this.apiEndpoint}/audio/register/${this.id}`)
|
||||
utils.writeLog(`_register error: ${error}`);
|
||||
utils.writeLog(`_register response: ${JSON.stringify(response).body}`);
|
||||
utils.writeLog(`_register body: ${body}`);
|
||||
if (!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||
utils.writeLog(`Asset ${this.id} audio registered`);
|
||||
return callback();
|
||||
@ -240,6 +244,10 @@ class Asset {
|
||||
}
|
||||
},
|
||||
(error, response, body) => {
|
||||
utils.writeLog(`_moveToChannel ERROR --- ${this.apiEndpoint}/audio/enter-group/${this.id}/${this.groupId}`)
|
||||
utils.writeLog(`_moveToChannel error: ${error}`);
|
||||
utils.writeLog(`_moveToChannel response: ${JSON.stringify(response).body}`);
|
||||
utils.writeLog(`_moveToChannel body: ${body}`);
|
||||
if (!error && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||
let hub = this.hub;
|
||||
if (hub && hub.connected) {
|
||||
@ -327,17 +335,29 @@ class Asset {
|
||||
utils.writeLog(`Error getting record for asset ${this.id} | ${error}`);
|
||||
utils.writeErrorLog(`ERROR_RECORDER`);
|
||||
}
|
||||
|
||||
const settings = configs.settings;
|
||||
let testing_period = 1000;
|
||||
if(settings.hasOwnProperty('testing_period')) { testing_period = parseInt(settings.testing_period, 10); }
|
||||
const exit_time = 13000 + testing_period;
|
||||
setTimeout(() => {
|
||||
utils.writeLog('STOP')
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, exit_time);
|
||||
let assetIds = configs.assets.ids;
|
||||
|
||||
console.log('id', this.id, 'total', assetIds)
|
||||
console.log('assetIds[0]', assetIds[0])
|
||||
console.log('max', Math.max(...assetIds))
|
||||
if(Math.max(...assetIds) == this.id) {
|
||||
setTimeout(() => {
|
||||
utils.writeLog('STOP')
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, 7000);
|
||||
}
|
||||
// const settings = configs.settings;
|
||||
// let testing_period = 1000;
|
||||
// if(settings.hasOwnProperty('testing_period')) { testing_period = parseInt(settings.testing_period, 10); }
|
||||
// const exit_time = 13000 + testing_period;
|
||||
// setTimeout(() => {
|
||||
// utils.writeLog('STOP')
|
||||
// .then(() => {
|
||||
// process.exit(0);
|
||||
// });
|
||||
// }, exit_time);
|
||||
|
||||
}
|
||||
);
|
||||
|
@ -35,13 +35,19 @@ class Simulator {
|
||||
|
||||
_start() {
|
||||
const settings = this.configs.settings;
|
||||
this.assetIds.forEach(id => {
|
||||
let testing_period = 1000;
|
||||
|
||||
this.assetIds.forEach((id, i) => {
|
||||
let testing_period = 500;
|
||||
if(settings.hasOwnProperty('testing_period')) {
|
||||
testing_period = parseInt(settings.testing_period, 10);
|
||||
}
|
||||
console.log('id', id, i * testing_period+'ms')
|
||||
|
||||
testing_period = this._getRandomInt(testing_period);
|
||||
setTimeout(() => { new Asset(id, this.configs, this.token); }, testing_period);
|
||||
setTimeout(() => {
|
||||
|
||||
new Asset(id, this.configs, this.token);
|
||||
}, i * testing_period);
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user