embark/lib/modules/webserver/backend/index.html

30 lines
526 B
HTML
Raw Normal View History

Welcome to Embark!
2018-02-26 14:45:46 +00:00
<script>
var ws = new WebSocket("ws://localhost:8000/logs");
ws.onopen = function() {
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt) {
var received_msg = evt.data;
console.log(received_msg);
//alert("Message is received...");
};
ws.onclose = function() {
// websocket is closed.
alert("Connection is closed...");
};
window.onbeforeunload = function(event) {
socket.close();
};
</script>