mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-21 12:49:11 +00:00
send logs to ws
This commit is contained in:
parent
fd83cba4b7
commit
925ae068b0
@ -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) {
|
||||
var received_msg = evt.data;
|
||||
console.log(received_msg);
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
|
@ -16,7 +16,7 @@ class WebServer {
|
||||
this.port = options.port || this.webServerConfig.port;
|
||||
|
||||
this.events.emit("status", __("Starting Server"));
|
||||
this.server = new Server({logger: this.logger, host: this.host, port: this.port});
|
||||
this.server = new Server({logger: this.logger, host: this.host, port: this.port, events: this.events});
|
||||
|
||||
this.setServiceCheck();
|
||||
this.listenToCommands();
|
||||
|
@ -8,6 +8,7 @@ var expressWebSocket = require('express-ws');
|
||||
|
||||
class Server {
|
||||
constructor(options) {
|
||||
this.events = options.events;
|
||||
this.dist = options.dist || 'dist/';
|
||||
this.port = options.port || 8000;
|
||||
this.hostname = options.host || 'localhost';
|
||||
@ -28,14 +29,13 @@ class Server {
|
||||
var app = express();
|
||||
|
||||
app.use(serve);
|
||||
app.use('/backend', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
|
||||
app.use('/embark', serveStatic(path.join(__dirname, 'backend'), {'backend': ['index.html', 'index.htm']}));
|
||||
|
||||
expressWebSocket(app);
|
||||
|
||||
app.ws('/logs', function(ws, req) {
|
||||
app.ws('/embark/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");
|
||||
@ -44,9 +44,9 @@ class Server {
|
||||
});
|
||||
});
|
||||
|
||||
//app.get('/embark', function (req, res) {
|
||||
// res.send('Welcome to Embark')
|
||||
//});
|
||||
app.get('/embark', function (req, res) {
|
||||
res.send('Welcome to Embark')
|
||||
});
|
||||
|
||||
app.listen(this.port);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user