From d40ceb834331753617b7d2e0c64cf0d312345104 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Mon, 24 May 2021 13:38:19 +0200 Subject: [PATCH] Refactor list of notification channels into its own file --- lib/www/server/lib/db/channels.js | 13 +++++++++++++ lib/www/server/ws/index.js | 9 +-------- 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 lib/www/server/lib/db/channels.js diff --git a/lib/www/server/lib/db/channels.js b/lib/www/server/lib/db/channels.js new file mode 100644 index 0000000..3ec6d99 --- /dev/null +++ b/lib/www/server/lib/db/channels.js @@ -0,0 +1,13 @@ + +// This is the list of all channels for which the +// database issues notifications. +// NOTE: This needs to be kept up to date with +// database schema changes. + +module.exports = [ + "realtime", "event", "project", + "preplot_lines", "preplot_points", + "planned_lines", + "raw_lines", "raw_shots", + "final_lines", "final_shots", "info" +]; diff --git a/lib/www/server/ws/index.js b/lib/www/server/ws/index.js index ea0d595..fc8143b 100644 --- a/lib/www/server/ws/index.js +++ b/lib/www/server/ws/index.js @@ -1,17 +1,10 @@ const ws = require('ws'); const URL = require('url'); const db = require('./db'); +const channels = require('../lib/db/channels'); function start (server, pingInterval=30000) { - const channels = [ - "realtime", "event", "project", - "preplot_lines", "preplot_points", - "planned_lines", - "raw_lines", "raw_shots", - "final_lines", "final_shots", "info" - ]; - const wsServer = new ws.Server({ noServer: true }); wsServer.on('connection', socket => { socket.alive = true;