LAPI-467: Update simulator to use mumble password
This commit is contained in:
28
src/asset.js
28
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) {
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user