Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// display
console.info("DefaultServient configured with");
console.dir(this.config);
// apply config
if (typeof this.config.servient.staticAddress === "string") {
Helpers.setStaticAddress(this.config.servient.staticAddress);
}
if (!this.config.servient.clientOnly) {
if (this.config.http !== undefined) {
let httpServer = new HttpServer(this.config.http);
this.addServer(httpServer);
// re-use httpServer (same port)
this.addServer(new WebSocketServer(httpServer));
}
if (this.config.coap !== undefined) {
// var to reuse below in CoapClient
var coapServer = (typeof this.config.coap.port === "number") ? new CoapServer(this.config.coap.port) : new CoapServer();
this.addServer(coapServer);
}
if (this.config.mqtt !== undefined) {
let mqttBrokerServer = new MqttBrokerServer(this.config.mqtt.broker,
(typeof this.config.mqtt.username === "string") ? this.config.mqtt.username : undefined,
(typeof this.config.mqtt.password === "string") ? this.config.mqtt.password : undefined,
(typeof this.config.mqtt.clientId === "string") ? this.config.mqtt.clientId : undefined,
(typeof this.config.mqtt.protocolVersion === "number") ? this.config.mqtt.protocolVersion : undefined);
this.addServer(mqttBrokerServer);
}
}