Browse Source

Rename connect method in JS and add some feedback messages

fastled
Xose Pérez 7 years ago
parent
commit
04c6fdb1b1
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      code/html/custom.js

+ 12
- 6
code/html/custom.js View File

@ -335,14 +335,20 @@ function getJson(str) {
}
}
function initWebSocket(host) {
if (host === undefined) {
function connect(host) {
if (typeof host === 'undefined') {
host = window.location.hostname;
}
websock = new WebSocket('ws://' + host + '/ws');
websock.onopen = function(evt) {};
websock.onclose = function(evt) {};
websock.onerror = function(evt) {};
websock.onopen = function(evt) {
console.log("Connected");
};
websock.onclose = function(evt) {
console.log("Disconnected");
};
websock.onerror = function(evt) {
console.log("Error: ", evt);
};
websock.onmessage = function(evt) {
var data = getJson(evt.data);
if (data) processData(data);
@ -363,7 +369,7 @@ function init() {
'method': 'GET',
'url': '/auth'
}).done(function(data) {
initWebSocket();
connect();
});
}


Loading…
Cancel
Save