message browser to client working

This commit is contained in:
Markus Sattler
2015-05-22 20:35:51 +02:00
parent e7a33beb6e
commit a14a58dbd2
5 changed files with 293 additions and 85 deletions

View File

@ -2,26 +2,21 @@
<head>
<script>
var connection = new WebSocket('ws://10.11.2.1:81/test', ['esp8266']);
var connection = new WebSocket('ws://10.11.2.1:81/test', ['esp8266', 'test']);
// When the connection is open, send some data to the server
connection.onopen = function () {
connection.send('ping'); // Send the message 'Ping' to the server
connection.send('Message from Browser to ESP8266 yay its Working!!');
connection.send('ping');
};
// Log errors
connection.onerror = function (error) {
console.log('WebSocket Error ' + error);
console.log('WebSocket Error ', error);
};
// Log messages from the server
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
console.log('Server: ', e.data);
};
</script>
</head>