« 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.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/index.js b/index.js
index b0db6cd..03b5bb1 100755
--- a/index.js
+++ b/index.js
@@ -75,7 +75,7 @@ async function main() {
     'player-options': {type: 'series'},
     'stress-test': {type: 'flag'},
     'socket-client': {type: 'value'},
-    'socket-server': {type: 'flag'},
+    'socket-server': {type: 'value'},
     'telnet-server': {type: 'flag'},
     [parseOptions.handleDashless](option) {
       playlistSources.push(option)
@@ -147,20 +147,26 @@ async function main() {
     appElement.attachAsServerHost(telnetServer)
   }
 
+  let socketClient
   let socketServer
   if (options['socket-server']) {
     socketServer = makeSocketServer()
     attachSocketServerToBackend(socketServer, backend)
-    socketServer.listen(1255)
+    socketServer.listen(options['socket-server'])
+
+    socketClient = makeSocketClient()
+    socketClient.socket.connect(options['socket-server'])
   }
 
-  let socketClient
   if (options['socket-client']) {
     socketClient = makeSocketClient()
+    socketClient.socket.connect(options['socket-client'])
+  }
+
+  if (socketClient) {
     attachBackendToSocketClient(backend, socketClient, {
       getPlaylistSources: () => appElement.playlistSources
     })
-    socketClient.socket.connect(1255)
   }
 
   if (options['stress-test']) {