diff --git a/server/services/socket.js b/server/services/socket.js index 1be7385..d2f8bc7 100644 --- a/server/services/socket.js +++ b/server/services/socket.js @@ -15,10 +15,16 @@ module.exports = (server) => { }); socket.on('data', (data) => { - const {measurement, pointName} = data; + pub.publish('console', JSON.stringify(data)); + }); + + sub.on('message', (channel, data) => { + const {measurement, pointName} = JSON.parse(data); - pub.publish('data', measurement); + io.emit('console', {measurement}) iWrite(pointName, socket.id, measurement) - }) + }); + + sub.subscribe('console') }); } \ No newline at end of file diff --git a/web/src/views/Dashboard.vue b/web/src/views/Dashboard.vue index b480657..8d2feaa 100644 --- a/web/src/views/Dashboard.vue +++ b/web/src/views/Dashboard.vue @@ -32,6 +32,10 @@ export default class Dashboard extends Vue { console.log(('Reconnecting...')); }); + + this.socket.on('console', (data: {}) => { + console.log(data); + }) } }