mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-24 12:57:13 +02:00
First steps to do async
This commit is contained in:
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user