diff options
author | Florrie <towerofnix@gmail.com> | 2020-07-10 11:28:34 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-16 18:37:00 -0300 |
commit | 90cad535c470fffa5c34c48737e44c1641416f0d (patch) | |
tree | 6b46582ea6d4a5585065d3a50ad3805ed047a4fb /index.js | |
parent | 3f17023373f3fa26ccb556ab1f83215b2a134e8c (diff) |
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!
Diffstat (limited to 'index.js')
-rwxr-xr-x | index.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/index.js b/index.js index 7632844..0553808 100755 --- a/index.js +++ b/index.js @@ -4,11 +4,22 @@ import {getPlayer} from './players.js' import {parseOptions} from './general-util.js' -import {getItemPathString} from './playlist-utils.js' import Backend from './backend.js' import setupClient from './client.js' import TelnetServer from './telnet.js' +import { + attachBackendToSocketClient, + attachSocketServerToBackend, + makeSocketServer, + makeSocketClient, +} from './socket.js' + +import { + getItemPathString, + updatePlaylistFormat, +} from './playlist-utils.js' + import {CommandLineInterface} from 'tui-lib/util/interfaces' import * as ansi from 'tui-lib/util/ansi' @@ -52,6 +63,8 @@ async function main() { 'player-options': {type: 'series'}, 'stress-test': {type: 'flag'}, + 'socket-client': {type: 'value'}, + 'socket-server': {type: 'flag'}, 'telnet-server': {type: 'flag'}, 'skip-config-file': {type: 'flag'}, 'config-file': {type: 'value'}, @@ -164,6 +177,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 |