From 503a37ba4d7550f9c2ed1602e589a0142a20d10d Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 10 Jul 2020 11:28:34 -0300 Subject: basic working backend save/restore & socket server Backend save/restore code (living in serialized-backend.js) has been well tested and shouldn't need much change going forward. Now we get to begin working on the actual synchronized-over-socket-server commands! --- index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'index.js') diff --git a/index.js b/index.js index 444d579..b0db6cd 100755 --- a/index.js +++ b/index.js @@ -11,6 +11,13 @@ const TelnetServer = require('./telnet') const processSmartPlaylist = require('./smart-playlist') const setupClient = require('./client') +const { + makeSocketServer, + makeSocketClient, + attachBackendToSocketClient, + attachSocketServerToBackend +} = require('./socket') + const { getItemPathString, updatePlaylistFormat @@ -67,6 +74,8 @@ async function main() { }, 'player-options': {type: 'series'}, 'stress-test': {type: 'flag'}, + 'socket-client': {type: 'value'}, + 'socket-server': {type: 'flag'}, 'telnet-server': {type: 'flag'}, [parseOptions.handleDashless](option) { playlistSources.push(option) @@ -138,6 +147,22 @@ async function main() { appElement.attachAsServerHost(telnetServer) } + let socketServer + if (options['socket-server']) { + socketServer = makeSocketServer() + attachSocketServerToBackend(socketServer, backend) + socketServer.listen(1255) + } + + let socketClient + if (options['socket-client']) { + socketClient = makeSocketClient() + attachBackendToSocketClient(backend, socketClient, { + getPlaylistSources: () => appElement.playlistSources + }) + socketClient.socket.connect(1255) + } + if (options['stress-test']) { await loadPlaylistPromise -- cgit 1.3.0-6-gf8a5