minor refactor on setprovider code

This commit is contained in:
Iuri Matias 2017-12-15 18:02:50 -05:00
parent e8ebb0fb37
commit c4e13f9ea8
1 changed files with 5 additions and 9 deletions

View File

@ -220,15 +220,12 @@ class CodeGenerator {
result += Templates.define_when_env_loaded();
let block;
//if (self.communicationConfig.enabled === true && ['whisper', 'orbit'].indexOf(self.communicationConfig.provider) < 0) {
// //TODO: add logger; also make sure it would still work with a plugin provider
// self.logger.warn("unknown provider " + self.communicationConfig.provider);
//}
// TODO: refactor this
if (self.communicationConfig.provider === 'whisper' && self.communicationConfig.enabled === true) {
if (self.communicationConfig.connection === undefined) {
block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');";
} else {
block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "', {server: '" + self.communicationConfig.connection.host + "', port: '" + self.communicationConfig.connection.port + "', type: '" + self.communicationConfig.connection.type + "'});";
}
result += Templates.exec_when_env_loaded({block: block});
} else if (self.communicationConfig.provider === 'orbit' && self.communicationConfig.enabled === true) {
if (self.communicationConfig.enabled === true) {
if (self.communicationConfig.connection === undefined) {
block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');";
} else {
@ -236,7 +233,6 @@ class CodeGenerator {
}
result += Templates.exec_when_env_loaded({block: block});
}
return result;
}