Fix whitespace
This commit is contained in:
1 parent
0155a5557e
commit
988d2ada35
2 files changed
+103
-104
No files matched your search
+20
-21
@@ -5,38 +5,37 @@ var colorOn = "\x1b[30;47m";
|
||||
var colorOff = "\x1b[0m";
|
||||
|
||||
function SmartHomeNGConnection(platform, log, host, port) {
|
||||
this.log = log;
|
||||
this.platform = platform;
|
||||
this.connected = false;
|
||||
this.updateCallback = undefined;
|
||||
this.tomonitor = [];
|
||||
this.retryTimer = 10;
|
||||
|
||||
this.shng_host = host;
|
||||
this.shng_port = port;
|
||||
|
||||
this.log = log;
|
||||
this.platform = platform;
|
||||
this.connected = false;
|
||||
this.updateCallback = undefined;
|
||||
this.tomonitor = [];
|
||||
this.retryTimer = 10;
|
||||
|
||||
this.shng_host = host;
|
||||
this.shng_port = port;
|
||||
}
|
||||
|
||||
SmartHomeNGConnection.prototype.init = function () {
|
||||
var that = this;
|
||||
this.shng_ws = new WebSocketClient();
|
||||
this.shng_ws.on('connect', function(connection) {
|
||||
that.log('[SmartHomeNGConnection] connected to server!');
|
||||
that.log('[SmartHomeNGConnection] connected to server!');
|
||||
that.connected = true;
|
||||
that.connection = connection;
|
||||
that.idenfityMyself();
|
||||
that.startMonitoring();
|
||||
|
||||
connection.on('message', function(message) { that.receive(message); });
|
||||
connection.on('error', function(error) {
|
||||
that.log(colorOn + '[SmartHomeNGConnection] WebSocket error: ' + error.toString() + colorOff)
|
||||
|
||||
connection.on('message', function(message) { that.receive(message); });
|
||||
connection.on('error', function(error) {
|
||||
that.log(colorOn + '[SmartHomeNGConnection] WebSocket error: ' + error.toString() + colorOff)
|
||||
});
|
||||
connection.on('close', function(code, description) {
|
||||
that.log(colorOn + '[SmartHomeNGConnection] Connection to smarthome lost, retrying in ' + that.retryTimer + ' seconds. ' + description + colorOff);
|
||||
that.connected = false;
|
||||
setTimeout(that.connect.bind(that), that.retryTimer * 1000);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
this.shng_ws.on('connectFailed', function(errorDescription) {
|
||||
@@ -49,13 +48,13 @@ SmartHomeNGConnection.prototype.init = function () {
|
||||
}
|
||||
|
||||
SmartHomeNGConnection.prototype.connect = function(host, ip) {
|
||||
this.log("[SmartHomeNGConnection] Connecting to SmartHomeNG @ " + this.shng_host);
|
||||
this.log("[SmartHomeNGConnection] Connecting to SmartHomeNG @ " + this.shng_host);
|
||||
this.shng_ws.connect('ws://' + this.shng_host + ':' + this.shng_port + '/');
|
||||
|
||||
|
||||
}
|
||||
|
||||
SmartHomeNGConnection.prototype.receive = function(message) {
|
||||
var msg = JSON.parse(message.utf8Data);
|
||||
var msg = JSON.parse(message.utf8Data);
|
||||
//this.log(msg);
|
||||
if (msg.items) {
|
||||
for (int = 0; int < msg.items.length; int++) {
|
||||
@@ -91,7 +90,7 @@ SmartHomeNGConnection.prototype.idenfityMyself = function() {
|
||||
}
|
||||
}
|
||||
|
||||
SmartHomeNGConnection.prototype.startMonitoring = function() {
|
||||
SmartHomeNGConnection.prototype.startMonitoring = function() {
|
||||
if (this.connected && this.tomonitor.length > 0) {
|
||||
var buffer = {};
|
||||
this.log("[SmartHomeNGConnection] Start monitoring " + this.tomonitor);
|
||||
@@ -105,6 +104,6 @@ SmartHomeNGConnection.prototype.startMonitoring = function() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SmartHomeNGConnection: SmartHomeNGConnection
|
||||
SmartHomeNGConnection: SmartHomeNGConnection
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user