93993793 by Jabis Sevon

interfacing with existing socket.io

1 parent 29484dc7
...@@ -1551,8 +1551,9 @@ ...@@ -1551,8 +1551,9 @@
1551 Chart.defaults.global.elements.line.backgroundColor = "rgba(0,0,0,0)"; 1551 Chart.defaults.global.elements.line.backgroundColor = "rgba(0,0,0,0)";
1552 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)"; 1552 Chart.defaults.global.elements.line.borderColor = "rgba(0,0,0,0.9)";
1553 Chart.defaults.global.elements.line.borderWidth = 2; 1553 Chart.defaults.global.elements.line.borderWidth = 2;
1554 1554 var config = {};
1555 var socket = io.connect(location.protocol + '//' + location.hostname + ':' + location.port); 1555 config.path = '/status';
1556 var socket = io.connect(location.protocol + '//' + location.hostname + ':' + location.port+''+config.path);
1556 var defaultSpan = 0; 1557 var defaultSpan = 0;
1557 var spans = []; 1558 var spans = [];
1558 1559
...@@ -1739,4 +1740,4 @@ ...@@ -1739,4 +1740,4 @@
1739 </script> 1740 </script>
1740 </body> 1741 </body>
1741 1742
1742 </html>
...\ No newline at end of file ...\ No newline at end of file
1743 </html>
......
...@@ -85,11 +85,12 @@ ...@@ -85,11 +85,12 @@
85 }); 85 });
86 86
87 return (req, res, next) => { 87 return (req, res, next) => {
88 if (io === null || io === undefined) { 88 if(global.socket) io = global.socket;
89 if (io === null || io === undefined || global.socket === undefined || global.socket === null) {
89 //console.log(req) 90 //console.log(req)
90 io = require('socket.io').listen(server); 91 io = require('socket.io').listen(server);
91 92 }
92 io.on('connection', (socket) => { 93 io.of(config.path).on('connection', (socket) => {
93 socket.emit('start', config.spans); 94 socket.emit('start', config.spans);
94 socket.on('change', function() { 95 socket.on('change', function() {
95 socket.emit('start', config.spans); 96 socket.emit('start', config.spans);
...@@ -101,7 +102,7 @@ ...@@ -101,7 +102,7 @@
101 span.responses = []; 102 span.responses = [];
102 setInterval(() => gatherOsMetrics(io, span), span.interval * 1000); 103 setInterval(() => gatherOsMetrics(io, span), span.interval * 1000);
103 }); 104 });
104 } 105
105 106
106 const startTime = process.hrtime(); 107 const startTime = process.hrtime();
107 if (req.path === config.path) { 108 if (req.path === config.path) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!