diff --git a/config/169/default.toml b/config/169/default.toml index e34f9fb..0c93439 100644 --- a/config/169/default.toml +++ b/config/169/default.toml @@ -24,6 +24,9 @@ gps_lng_start_point = 24.776126 testing_period = 1500 [assets] +# linx-simulator-1 +ids = [15] + # linx-simulator-1 - linx-simulator-10 # ids = [15,16,17,18,19,20,21,22,23,24] @@ -35,13 +38,13 @@ testing_period = 1500 # ] # linx-simulator-1 - linx-simulator-50 -ids = [ - 15,16,17,18,19,20,21,22,23,24, - 25,26,27,28,29,30,31,32,33,34, - 35,36,37,38,39,40,41,42,43,44, - 45,46,47,48,49,50,51,52,53,54, - 55,56,57,58,59,60,61,62,63,64 -] +# ids = [ +# 15,16,17,18,19,20,21,22,23,24, +# 25,26,27,28,29,30,31,32,33,34, +# 35,36,37,38,39,40,41,42,43,44, +# 45,46,47,48,49,50,51,52,53,54, +# 55,56,57,58,59,60,61,62,63,64 +# ] [sounds] sound = 'sound.mp3' diff --git a/src/asset.js b/src/asset.js index b322573..38b7760 100644 --- a/src/asset.js +++ b/src/asset.js @@ -27,6 +27,7 @@ class Asset { this.startTime = +new Date(); this.pttEndSuccessfully = false; this.assetProps = {}; + this.murmurPassword = ''; utils.writeLog(`Creating asset ${id}`) @@ -87,6 +88,32 @@ class Asset { // Here are the asset fields. this.assetProps = bodyObj.data; // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps) + return this._getMumblePassword(callback); + } else { + utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeErrorLog(`ERROR_API`); + return callback(error); + } + } + ); + } + + _getMumblePassword(callback) { + utils.writeLog(`Get Mumble password for asset ${this.id}`); + Request.get( + this.apiEndpoint + '/asset/' + this.id + '/account', + { + headers: { + Authorization: `Bearer ${this.token}` + } + }, + (error, response, body) => { + if (!error && (response.statusCode === 200 || response.statusCode === 201)) { + let bodyObj = JSON.parse(body); + + // Here are the asset fields. + this.murmurPassword = bodyObj.data.configuration.mumble_password; + // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps) return this._getGroupsFromApi(callback); } else { utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); @@ -195,6 +222,7 @@ class Asset { } _connectToMurmur(callback) { + this.configs.murmurPassword = this.murmurPassword; this.mumble = new Mumble(this.id, this.configs, (err) => { if (err) { diff --git a/src/mumble.js b/src/mumble.js index e6d077b..6b7d1d3 100644 --- a/src/mumble.js +++ b/src/mumble.js @@ -12,12 +12,12 @@ const OpusEncoder = require('node-opus').OpusEncoder; class Mumble { constructor(id, configs, connectedCallback) { - + console.log('------', configs) this.id = id; this.configs = configs; let mumble = configs.mumble; this._createCertificatesForUser(id, () => { - this._makeMumbleConnection(id, mumble.port, mumble.host, id, id, connectedCallback); + this._makeMumbleConnection(id, mumble.port, mumble.host, id, this.configs.murmurPassword, connectedCallback); }) } @@ -87,7 +87,7 @@ class Mumble { // Connect to mumble server. this.client = new MumbleClient({ username: '' + username, - password: '' + password, + password, codecs: NodeCodecs }); this.client.connectDataStream(this.socket);