First steps to do async

This commit is contained in:
Markus Sattler
2016-01-23 16:27:02 +01:00
parent ece771a275
commit 57e30e0634
8 changed files with 435 additions and 206 deletions

View File

@ -8,10 +8,11 @@ connection.onopen = function () {
connection.send('Message from Browser to ESP8266 yay its Working!! ' + new Date());
connection.send('ping');
setInterval(function() {
/* setInterval(function() {
connection.send('Time: ' + new Date());
}, 20);
*/
connection.send('Time: ' + new Date());
};
connection.onerror = function (error) {
@ -20,6 +21,7 @@ connection.onerror = function (error) {
connection.onmessage = function (e) {
console.log('Server: ', e.data);
connection.send('Time: ' + new Date());
};
function sendRGB() {

View File

@ -41,11 +41,11 @@ wsServer.on('request', function(request) {
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log('Received Message: ' + message.utf8Data);
connection.sendUTF(message.utf8Data);
// connection.sendUTF(message.utf8Data);
}
else if (message.type === 'binary') {
console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
connection.sendBytes(message.binaryData);
//connection.sendBytes(message.binaryData);
}
});