diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index df6698a..cf9e731 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,8 +3,8 @@
-
+
@@ -28,8 +28,8 @@
-
-
+
+
@@ -48,8 +48,8 @@
-
-
+
+
@@ -462,18 +462,6 @@
1447021065296
-
- 1447023017687
-
-
- 1447023017687
-
-
- 1447030070358
-
-
- 1447030070358
-
1447055263421
@@ -738,7 +726,37 @@
1455705443426
-
+
+ 1455707085360
+
+
+ 1455707085360
+
+
+ 1455707397224
+
+
+ 1455707397225
+
+
+ 1455707426616
+
+
+ 1455707426616
+
+
+ 1455707818885
+
+
+ 1455707818938
+
+
+ 1455708009465
+
+
+ 1455708009465
+
+
@@ -751,7 +769,7 @@
-
+
@@ -793,6 +811,7 @@
+
@@ -1183,14 +1202,6 @@
-
-
-
-
-
-
-
-
@@ -1199,10 +1210,18 @@
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/routes/temp.js b/routes/temp.js
index 77b7a24..98b221b 100644
--- a/routes/temp.js
+++ b/routes/temp.js
@@ -174,7 +174,7 @@ wsServer.on('request', function (request) {
return;
}
- var connection = request.accept('', request.origin);
+ var connection = request.accept('stream', request.origin);
logger.debug((new Date()) + ' Connection accepted.');
var sendSocketHandler = (obj) => {
@@ -199,4 +199,4 @@ wsServer.on('request', function (request) {
logger.debug((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
busEmitter.removeListener('sendSocket', sendSocketHandler);
});
-});;
+});;;
diff --git a/views/temp.ejs b/views/temp.ejs
index d887fad..255e27f 100644
--- a/views/temp.ejs
+++ b/views/temp.ejs
@@ -95,6 +95,59 @@
}
);
+
+
+
+
+
+ (function () {
+ console.log('Starting socket?');
+ var url = "ws://api.silvrtree.co.uk:8085";
+
+ var wsCtor = window['MozWebSocket'] ? MozWebSocket : WebSocket;
+ this.socket = new wsCtor(url, 'stream');
+
+
+
+
+ this.handleData = function(d) {
+ switch(d.id) {
+ case 'LightingDataReceived':
+ // this.updateLighting(d.sensorData.d);
+ break;
+ case 'ProjectorDataReceived':
+ // this.updateProj(d.sensorData.d);
+ break;
+ case 'HeatingDataReceived':
+ break;
+ default:
+ }
+ };
+
+
+ this.handleWebsocketMessage = function (message) {
+ try {
+ var command = JSON.parse(message.data);
+ }
+ catch (e) { /* do nothing */
+ }
+
+ if (command) {
+ //this.dispatchCommand(command);
+ this.handleData(command);
+ }
+ };
+
+ this.handleWebsocketClose = function () {
+ alert("WebSocket Connection Closed.");
+ };
+
+ this.socket.onmessage = this.handleWebsocketMessage.bind(this);
+ this.socket.onclose = this.handleWebsocketClose.bind(this);
+ })();
+
+
+