« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rwxr-xr-xindex.js31
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