« get me outta code hell

basic command relay across socket clients - 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:
authorFlorrie <towerofnix@gmail.com>2020-07-10 20:52:13 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-16 18:45:31 -0300
commite6698a135099348b62d295e904580f4341447958 (patch)
treee9422919b5b1af0643f7bc53d7145d109d6cbcf8 /index.js
parent90cad535c470fffa5c34c48737e44c1641416f0d (diff)
basic command relay across socket clients
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 0553808..97b9504 100755
--- a/index.js
+++ b/index.js
@@ -64,7 +64,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'},
     'skip-config-file': {type: 'flag'},
     'config-file': {type: 'value'},
@@ -177,20 +177,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']) {