send logs to ws

This commit is contained in:
Iuri Matias 2018-02-26 17:44:09 -05:00 committed by Pascal Precht
parent 7bd6b9da8f
commit ceb107f43b
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 14 additions and 22 deletions

View File

@ -1,29 +1,22 @@
Welcome to Embark!
<script>
var ws = new WebSocket("ws://localhost:8000/embark/logs");
var ws = new WebSocket("ws://localhost:8000/logs");
ws.onopen = function() {
};
ws.onopen = function() {
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt) {
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();
};
ws.onclose = function() {
console.log("Connection is closed...");
};
window.onbeforeunload = function(event) {
ws.close();
};
</script>

View File

@ -69,8 +69,7 @@ class Server {
this.app.ws('/logs', function(ws, req) {
self.events.on("log", function(logLevel, logMsg) {
console.dir("got message " + logMsg);
ws.send(logMsg);
ws.send(logMsg.stripColors);
});
ws.on('message', function(msg) {
console.dir("got message");