LAPI-467: Update simulator to use mumble password
This commit is contained in:
parent
90b8379e65
commit
5cc8860e0c
@ -24,6 +24,9 @@ gps_lng_start_point = 24.776126
|
|||||||
testing_period = 1500
|
testing_period = 1500
|
||||||
|
|
||||||
[assets]
|
[assets]
|
||||||
|
# linx-simulator-1
|
||||||
|
ids = [15]
|
||||||
|
|
||||||
# linx-simulator-1 - linx-simulator-10
|
# linx-simulator-1 - linx-simulator-10
|
||||||
# ids = [15,16,17,18,19,20,21,22,23,24]
|
# ids = [15,16,17,18,19,20,21,22,23,24]
|
||||||
|
|
||||||
@ -35,13 +38,13 @@ testing_period = 1500
|
|||||||
# ]
|
# ]
|
||||||
|
|
||||||
# linx-simulator-1 - linx-simulator-50
|
# linx-simulator-1 - linx-simulator-50
|
||||||
ids = [
|
# ids = [
|
||||||
15,16,17,18,19,20,21,22,23,24,
|
# 15,16,17,18,19,20,21,22,23,24,
|
||||||
25,26,27,28,29,30,31,32,33,34,
|
# 25,26,27,28,29,30,31,32,33,34,
|
||||||
35,36,37,38,39,40,41,42,43,44,
|
# 35,36,37,38,39,40,41,42,43,44,
|
||||||
45,46,47,48,49,50,51,52,53,54,
|
# 45,46,47,48,49,50,51,52,53,54,
|
||||||
55,56,57,58,59,60,61,62,63,64
|
# 55,56,57,58,59,60,61,62,63,64
|
||||||
]
|
# ]
|
||||||
|
|
||||||
[sounds]
|
[sounds]
|
||||||
sound = 'sound.mp3'
|
sound = 'sound.mp3'
|
||||||
|
28
src/asset.js
28
src/asset.js
@ -27,6 +27,7 @@ class Asset {
|
|||||||
this.startTime = +new Date();
|
this.startTime = +new Date();
|
||||||
this.pttEndSuccessfully = false;
|
this.pttEndSuccessfully = false;
|
||||||
this.assetProps = {};
|
this.assetProps = {};
|
||||||
|
this.murmurPassword = '';
|
||||||
|
|
||||||
utils.writeLog(`Creating asset ${id}`)
|
utils.writeLog(`Creating asset ${id}`)
|
||||||
|
|
||||||
@ -87,6 +88,32 @@ class Asset {
|
|||||||
// Here are the asset fields.
|
// Here are the asset fields.
|
||||||
this.assetProps = bodyObj.data;
|
this.assetProps = bodyObj.data;
|
||||||
// console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps)
|
// 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);
|
return this._getGroupsFromApi(callback);
|
||||||
} else {
|
} else {
|
||||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||||
@ -195,6 +222,7 @@ class Asset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_connectToMurmur(callback) {
|
_connectToMurmur(callback) {
|
||||||
|
this.configs.murmurPassword = this.murmurPassword;
|
||||||
|
|
||||||
this.mumble = new Mumble(this.id, this.configs, (err) => {
|
this.mumble = new Mumble(this.id, this.configs, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -12,12 +12,12 @@ const OpusEncoder = require('node-opus').OpusEncoder;
|
|||||||
class Mumble {
|
class Mumble {
|
||||||
|
|
||||||
constructor(id, configs, connectedCallback) {
|
constructor(id, configs, connectedCallback) {
|
||||||
|
console.log('------', configs)
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.configs = configs;
|
this.configs = configs;
|
||||||
let mumble = configs.mumble;
|
let mumble = configs.mumble;
|
||||||
this._createCertificatesForUser(id, () => {
|
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.
|
// Connect to mumble server.
|
||||||
this.client = new MumbleClient({
|
this.client = new MumbleClient({
|
||||||
username: '' + username,
|
username: '' + username,
|
||||||
password: '' + password,
|
password,
|
||||||
codecs: NodeCodecs
|
codecs: NodeCodecs
|
||||||
});
|
});
|
||||||
this.client.connectDataStream(this.socket);
|
this.client.connectDataStream(this.socket);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user