Let websocket listen to all DB notification channels

This commit is contained in:
D. Berge
2020-10-02 00:39:53 +02:00
parent 902338f835
commit 746e3405fb

View File

@@ -4,6 +4,13 @@ const db = require('./db');
function start (server, pingInterval=30000) {
const channels = [
"realtime", "event", "project",
"preplot_lines", "preplot_points",
"raw_lines", "raw_shots",
"final_lines", "final_shots"
];
const wsServer = new ws.Server({ noServer: true });
wsServer.on('connection', socket => {
socket.alive = true;
@@ -21,7 +28,7 @@ function start (server, pingInterval=30000) {
}
});
db.listen(["realtime", "event", "project"], (data) => {
db.listen(channels, (data) => {
wsServer.clients.forEach( (socket) => {
socket.send(JSON.stringify(data));
})