« get me outta code hell

Merge branch 'main' into socket-mtui - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/socket.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-05-13 21:54:52 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-05-13 21:54:52 -0300
commit4ea5e57d2b6c12f42ff21c4b43056021553f07a0 (patch)
tree175c5c662639496fc859fa9a4852c363a6bab11d /socket.js
parent84c49e453336d6105655edd08e93bab071c0fc3b (diff)
parenta36e372ba88b59e08fa938f76b261fdc2797bef2 (diff)
Merge branch 'main' into socket-mtui
And also get most of it working wow.
Diffstat (limited to 'socket.js')
-rw-r--r--socket.js274
1 files changed, 134 insertions, 140 deletions
diff --git a/socket.js b/socket.js
index a40dc97..59f70d9 100644
--- a/socket.js
+++ b/socket.js
@@ -17,40 +17,41 @@
 // library from there. This would be handy for people with a VPN with its own
 // hostname and firewall protections!
 
-'use strict' // single quotes & no semicolons time babey
+// single quotes & no semicolons time babey
 
-// This is expected to be the same across both the client and the server.
-// There will probably be inconsistencies between sender clients and receiving
-// clients / the server otherwise.
-const DEFAULT_NICKNAME = '(Unnamed)'
-
-const originalSymbol = Symbol('Original item')
-
-const EventEmitter = require('events')
-const net = require('net')
-const shortid = require('shortid')
+import EventEmitter from 'node:events'
+import net from 'node:net'
 
-const {
-  saveBackend,
-  restoreBackend,
-  saveItemReference,
-  restoreNewItem,
-  updateRestoredTracksUsingPlaylists
-} = require('./serialized-backend')
+import shortid from 'shortid'
 
-const {
+import {
   getTimeStringsFromSec,
   parseWithoutPrototype,
-  silenceEvents
-} = require('./general-util')
+  silenceEvents,
+} from './general-util.js'
 
-const {
+import {
   parentSymbol,
   updateGroupFormat,
   updateTrackFormat,
   isTrack,
-  isGroup
-} = require('./playlist-utils')
+  isGroup,
+} from './playlist-utils.js'
+
+import {
+  restoreBackend,
+  restoreNewItem,
+  saveBackend,
+  saveItemReference,
+  updateRestoredTracksUsingPlaylists,
+} from './serialized-backend.js'
+
+// This is expected to be the same across both the client and the server.
+// There will probably be inconsistencies between sender clients and receiving
+// clients / the server otherwise.
+const DEFAULT_NICKNAME = '(Unnamed)'
+
+export const originalSymbol = Symbol('Original item')
 
 function serializePartySource(item) {
   // Turn an item into a sanitized, compact format for sharing with the server
@@ -156,7 +157,7 @@ function validateCommand(command) {
   switch (command.sender) {
     case 'server':
       switch (command.code) {
-        case 'initialize-party':
+        case 'initialize party':
           return (
             typeof command.backend === 'object' &&
             typeof command.socketInfo === 'object' &&
@@ -165,24 +166,24 @@ function validateCommand(command) {
               Array.isArray(info.sharedSources)
             ))
           )
-        case 'set-socket-id':
+        case 'set socket id':
           return typeof command.socketId === 'string'
       }
       // No break here; servers can send commands which typically come from
       // clients too.
     case 'client':
       switch (command.code) {
-        case 'announce-join':
+        case 'announce join':
           return true
-        case 'clear-queue':
+        case 'clear queue':
           return typeof command.queuePlayer === 'string'
-        case 'clear-queue-past':
-        case 'clear-queue-up-to':
+        case 'clear queue past':
+        case 'clear queue up to':
           return (
             typeof command.queuePlayer === 'string' &&
             isItemRef(command.track)
           )
-        case 'distribute-queue':
+        case 'distribute queue':
           return (
             typeof command.queuePlayer === 'string' &&
             isItemRef(command.topItem) &&
@@ -218,26 +219,26 @@ function validateCommand(command) {
               )
             ))
           )
-        case 'restore-queue':
+        case 'restore queue':
           return (
             typeof command.queuePlayer === 'string' &&
             Array.isArray(command.tracks) &&
             command.tracks.every(track => isItemRef(track)) &&
             ['shuffle'].includes(command.why)
           )
-        case 'seek-to':
+        case 'seek to':
           return (
             typeof command.queuePlayer === 'string' &&
             typeof command.time === 'number'
           )
-        case 'set-nickname':
+        case 'set nickname':
           return (
             typeof command.nickname === 'string' &&
             typeof command.oldNickname === 'string' &&
             command.nickname.length >= 1 &&
             command.nickname.length <= 12
           )
-        case 'set-pause':
+        case 'set pause':
           return (
             typeof command.queuePlayer === 'string' &&
             typeof command.paused === 'boolean' &&
@@ -246,21 +247,21 @@ function validateCommand(command) {
               command.sender === 'server'
             ) || !command.startingTrack
           )
-        case 'share-with-party':
+        case 'share with party':
           return (
             typeof command.item === 'string' ||
             Array.isArray(command.item)
           )
         case 'status':
           return (
-            command.status === 'done-playing' ||
+            command.status === 'done playing' ||
             (
-              command.status === 'ready-to-resume' &&
+              command.status === 'ready to resume' &&
               typeof command.queuePlayer === 'string'
             ) ||
-            command.status === 'sync-playback'
+            command.status === 'sync playback'
           )
-        case 'stop-playing':
+        case 'stop playing':
           return typeof command.queuePlayer === 'string'
         case 'unqueue':
           return (
@@ -297,7 +298,7 @@ function perLine(handleLine) {
   }
 }
 
-function makeSocketServer() {
+export function makeSocketServer() {
   // The socket server has two functions: to maintain a "canonical" backend
   // and synchronize newly connected clients with the relevent data in this
   // backend, and to receive command data from clients and relay this to
@@ -365,8 +366,8 @@ function makeSocketServer() {
 
       if (!socketInfo.hasAnnouncedJoin) {
         if (![
-          'announce-join',
-          'set-nickname'
+          'announce join',
+          'set nickname'
         ].includes(command.code)) {
           return
         }
@@ -377,7 +378,7 @@ function makeSocketServer() {
 
       if (command.code === 'status') {
         switch (command.status) {
-          case 'done-playing': {
+          case 'done playing': {
             const doneSockets = donePlaying[command.queuePlayer]
             if (doneSockets && !doneSockets.includes(socketId)) {
               doneSockets.push(socketId)
@@ -391,17 +392,17 @@ function makeSocketServer() {
             }
             break
           }
-          case 'ready-to-resume': {
+          case 'ready to resume': {
             const readySockets = readyToResume[command.queuePlayer]
             if (readySockets && !readySockets.includes(socketId)) {
               readySockets.push(socketId)
               if (readySockets.length === Object.keys(socketMap).length) {
-                const QP = server.canonicalBackend.queuePlayers.find(QP => QP.id === command.queuePlayer)
-                silenceEvents(QP, ['set-pause'], () => QP.setPause(false))
+                // const QP = server.canonicalBackend.queuePlayers.find(QP => QP.id === command.queuePlayer)
+                // silenceEvents(QP, ['set pause'], () => QP.setPause(false))
                 for (const socket of Object.values(socketMap)) {
                   socket.write(serializeCommandToData({
                     sender: 'server',
-                    code: 'set-pause',
+                    code: 'set pause',
                     queuePlayer: command.queuePlayer,
                     startingTrack: true,
                     paused: false
@@ -413,18 +414,18 @@ function makeSocketServer() {
             }
             break
           }
-          case 'sync-playback':
+          case 'sync playback':
             for (const QP of server.canonicalBackend.queuePlayers) {
               if (QP.timeData) {
                 socket.write(serializeCommandToData({
                   sender: 'server',
-                  code: 'seek-to',
+                  code: 'seek to',
                   queuePlayer: QP.id,
                   time: QP.timeData.curSecTotal
                 }) + '\n')
                 socket.write(serializeCommandToData({
                   sender: 'server',
-                  code: 'set-pause',
+                  code: 'set pause',
                   queuePlayer: QP.id,
                   startingTrack: true,
                   paused: QP.player.isPaused
@@ -442,31 +443,31 @@ function makeSocketServer() {
         readyToResume[command.queuePlayer] = []
       }
 
-      // If it's a 'set-nickname' command, save the nickname.
+      // If it's a 'set nickname' command, save the nickname.
       // Also attach the old nickname for display in log messages.
 
-      if (command.code === 'set-nickname') {
+      if (command.code === 'set nickname') {
         command.oldNickname = socketInfo.nickname
         command.senderNickname = socketInfo.nickname
         socketInfo.nickname = command.nickname
       }
 
-      // If it's a 'share-with-party' command, keep track of the item being
+      // If it's a 'share with party' command, keep track of the item being
       // shared, so we can synchronize newly joining sockets with it.
 
-      if (command.code === 'share-with-party') {
+      if (command.code === 'share with party') {
         const { sharedSources } = socketInfoMap[socketId]
         sharedSources.push(command.item)
       }
 
-      // If it's an 'announce-join' command, mark the variable for this!
+      // If it's an 'announce join' command, mark the variable for this!
 
-      if (command.code === 'announce-join') {
+      if (command.code === 'announce join') {
         socketInfo.hasAnnouncedJoin = true;
       }
 
       // If the socket hasn't announced its joining yet, don't relay the
-      // command. (Since hasAnnouncedJoin gets set above, 'announce-join'
+      // command. (Since hasAnnouncedJoin gets set above, 'announce join'
       // will pass this condition.)
 
       if (!socketInfo.hasAnnouncedJoin) {
@@ -492,13 +493,13 @@ function makeSocketServer() {
 
     socket.write(serializeCommandToData({
       sender: 'server',
-      code: 'set-socket-id',
+      code: 'set socket id',
       socketId
     }) + '\n')
 
     socket.write(serializeCommandToData({
       sender: 'server',
-      code: 'initialize-party',
+      code: 'initialize party',
       backend: savedBackend,
       socketInfo: socketInfoMap
     }) + '\n')
@@ -507,7 +508,7 @@ function makeSocketServer() {
   return server
 }
 
-function makeSocketClient() {
+export function makeSocketClient() {
   // The socket client connects to a server and sends/receives commands to/from
   // that server. This doesn't actually connect the socket to a port/host; that
   // is the caller's responsibility (use client.socket.connect()).
@@ -520,7 +521,7 @@ function makeSocketClient() {
   client.sendCommand = function(command) {
     const data = serializeCommandToData(command)
     client.socket.write(data + '\n')
-    client.emit('sent-command', command)
+    client.emit('sent command', command)
   }
 
   client.socket.on('data', perLine(line => {
@@ -544,7 +545,7 @@ function makeSocketClient() {
   return client
 }
 
-function attachBackendToSocketClient(backend, client) {
+export function attachBackendToSocketClient(backend, client) {
   // All actual logic for instances of the mtui backend interacting with each
   // other through commands lives here.
 
@@ -582,22 +583,22 @@ function attachBackendToSocketClient(backend, client) {
     let isVerbose = false
 
     switch (command.code) {
-      case 'announce-join':
+      case 'announce join':
         actionmsg = `joined the party`
         break
-      case 'clear-queue':
+      case 'clear queue':
         actionmsg = 'cleared the queue'
         break
-      case 'clear-queue-past':
+      case 'clear queue past':
         actionmsg = `cleared the queue past ${itemToMessage(command.track)}`
         break
-      case 'clear-queue-up-to':
+      case 'clear queue up to':
         actionmsg = `cleared the queue up to ${itemToMessage(command.track)}`
         break
-      case 'distribute-queue':
+      case 'distribute queue':
         actionmsg = `distributed ${itemToMessage(command.topItem)} across the queue ${command.opts.how}`
         break
-      case 'initialize-party':
+      case 'initialize party':
         return
       case 'play':
         actionmsg = `started playing ${itemToMessage(command.track)}`
@@ -612,37 +613,37 @@ function attachBackendToSocketClient(backend, client) {
         actionmsg = `queued ${itemToMessage(command.topItem)}` + afterMessage
         break
       }
-      case 'restore-queue':
+      case 'restore queue':
         if (command.why === 'shuffle') {
           actionmsg = 'shuffled the queue'
         }
         break
-      case 'share-with-party':
+      case 'share with party':
         // TODO: This isn't an outrageously expensive operation, but it still
         // seems a little unnecessary to deserialize it here if we also do that
         // when actually processing the source?
         actionmsg = `shared ${itemToMessage(deserializePartySource(command.item))} with the party`
         break
-      case 'seek-to':
+      case 'seek to':
         // TODO: the second value here should be the duration of the track
         // (this will make values like 0:0x:yy / 1:xx:yy appear correctly)
         actionmsg = `seeked to ${getTimeStringsFromSec(command.time, command.time).timeDone}`
         mayCombine = true
         break
-      case 'set-nickname':
+      case 'set nickname':
         actionmsg = `updated their nickname (from ${nickToMessage(command.oldNickname)})`
         senderNickname = command.nickname
         break
-      case 'set-socket-id':
+      case 'set socket id':
         return
-      case 'set-pause':
+      case 'set pause':
         if (command.paused) {
           actionmsg = 'paused the player'
         } else {
           actionmsg = 'resumed the player'
         }
         break
-      case 'stop-playing':
+      case 'stop playing':
         actionmsg = 'stopped the player'
         break
       case 'unqueue':
@@ -651,13 +652,13 @@ function attachBackendToSocketClient(backend, client) {
       case 'status':
         isVerbose = true
         switch (command.status) {
-          case 'ready-to-resume':
+          case 'ready to resume':
             actionmsg = `is ready to play!`
             break
-          case 'done-playing':
+          case 'done playing':
             actionmsg = `has finished playing`
             break
-          case 'sync-playback':
+          case 'sync playback':
             actionmsg = `synced playback with the server`
             break
           default:
@@ -676,7 +677,7 @@ function attachBackendToSocketClient(backend, client) {
     })
   }
 
-  client.on('sent-command', command => {
+  client.on('sent command', command => {
     command.senderNickname = client.nickname
     logCommand(command)
   })
@@ -686,7 +687,7 @@ function attachBackendToSocketClient(backend, client) {
     switch (command.sender) {
       case 'server':
         switch (command.code) {
-          case 'set-socket-id':
+          case 'set socket id':
             client.socketId = command.socketId
             socketInfoMap[command.socketId] = {
               nickname: client.nickname,
@@ -694,7 +695,7 @@ function attachBackendToSocketClient(backend, client) {
             }
             backend.loadSharedSources(command.socketId, sharedSources)
             return
-          case 'initialize-party':
+          case 'initialize party':
             for (const [ socketId, info ] of Object.entries(command.socketInfo)) {
               const nickname = info.nickname
 
@@ -714,11 +715,11 @@ function attachBackendToSocketClient(backend, client) {
               backend.loadSharedSources(socketId, sharedSources)
             }
             await restoreBackend(backend, command.backend)
-            backend.on('playing', QP => {
-              QP.once('received time data', () => {
-                client.sendCommand({code: 'status', status: 'sync-playback'})
-              })
-            })
+            // backend.on('QP: playing', QP => {
+            //   QP.once('received time data', () => {
+            //     client.sendCommand({code: 'status', status: 'sync playback'})
+            //   })
+            // })
             return
         }
         // Again, no break. Client commands can come from the server.
@@ -729,7 +730,7 @@ function attachBackendToSocketClient(backend, client) {
         )
 
         switch (command.code) {
-          case 'announce-join': {
+          case 'announce join': {
             const sharedSources = {
               name: namePartySources(command.senderNickname),
               isPartySources: true,
@@ -742,21 +743,21 @@ function attachBackendToSocketClient(backend, client) {
             backend.loadSharedSources(command.senderSocketId, sharedSources)
             return
           }
-          case 'clear-queue':
-            if (QP) silenceEvents(QP, ['clear-queue'], () => QP.clearQueue())
+          case 'clear queue':
+            if (QP) silenceEvents(QP, ['clear queue'], () => QP.clearQueue())
             return
-          case 'clear-queue-past':
-            if (QP) silenceEvents(QP, ['clear-queue-past'], () => QP.clearQueuePast(
+          case 'clear queue past':
+            if (QP) silenceEvents(QP, ['clear queue past'], () => QP.clearQueuePast(
               restoreNewItem(command.track, getPlaylistSources())
             ))
             return
-          case 'clear-queue-up-to':
-            if (QP) silenceEvents(QP, ['clear-queue-up-to'], () => QP.clearQueueUpTo(
+          case 'clear queue up to':
+            if (QP) silenceEvents(QP, ['clear queue up to'], () => QP.clearQueueUpTo(
               restoreNewItem(command.track, getPlaylistSources())
             ))
             return
-          case 'distribute-queue':
-            if (QP) silenceEvents(QP, ['distribute-queue'], () => QP.distributeQueue(
+          case 'distribute queue':
+            if (QP) silenceEvents(QP, ['distribute queue'], () => QP.distributeQueue(
               restoreNewItem(command.topItem),
               {
                 how: command.opts.how,
@@ -769,7 +770,7 @@ function attachBackendToSocketClient(backend, client) {
               QP.once('received time data', data => {
                 client.sendCommand({
                   code: 'status',
-                  status: 'ready-to-resume',
+                  status: 'ready to resume',
                   queuePlayer: QP.id
                 })
               })
@@ -787,24 +788,24 @@ function attachBackendToSocketClient(backend, client) {
               }
             ))
             return
-          case 'restore-queue':
+          case 'restore queue':
             if (QP) {
               QP.replaceAllItems(command.tracks.map(
                 refData => restoreNewItem(refData, getPlaylistSources())
               ))
             }
             return
-          case 'seek-to':
-            if (QP) silenceEvents(QP, ['seek-to'], () => QP.seekTo(command.time))
+          case 'seek to':
+            if (QP) silenceEvents(QP, ['seek to'], () => QP.seekTo(command.time))
             return
-          case 'set-nickname': {
+          case 'set nickname': {
             const info = socketInfoMap[command.senderSocketId]
             info.nickname = command.senderNickname
             info.sharedSources.name = namePartySources(command.senderNickname)
             backend.sharedSourcesUpdated(client.socketId, info.sharedSources)
             return
           }
-          case 'set-pause': {
+          case 'set pause': {
             // TODO: there's an event leak here when toggling pause while
             // nothing is playing
             let playingThisTrack = true
@@ -813,19 +814,19 @@ function attachBackendToSocketClient(backend, client) {
             })
             setTimeout(() => {
               if (playingThisTrack) {
-                if (QP) silenceEvents(QP, ['set-pause'], () => QP.setPause(command.paused))
+                if (QP) silenceEvents(QP, ['set pause'], () => QP.setPause(command.paused))
               }
             }, command.startingTrack ? 500 : 0)
             return
           }
-          case 'share-with-party': {
+          case 'share with party': {
             const { sharedSources } = socketInfoMap[command.senderSocketId]
             const deserialized = deserializePartySource(command.item, sharedSources)
             sharedSources.items.push(deserialized)
             backend.sharedSourcesUpdated(command.senderSocketId, sharedSources)
             return
           }
-          case 'stop-playing':
+          case 'stop playing':
             if (QP) silenceEvents(QP, ['playing'], () => QP.stopPlaying())
             return
           case 'unqueue':
@@ -838,47 +839,47 @@ function attachBackendToSocketClient(backend, client) {
     }
   })
 
-  backend.on('clear-queue', queuePlayer => {
+  backend.on('QP: clear queue', queuePlayer => {
     client.sendCommand({
-      code: 'clear-queue',
+      code: 'clear queue',
       queuePlayer: queuePlayer.id
     })
   })
 
-  backend.on('clear-queue-past', (queuePlayer, track) => {
+  backend.on('QP: clear queue past', (queuePlayer, track) => {
     client.sendCommand({
-      code: 'clear-queue-past',
+      code: 'clear queue past',
       queuePlayer: queuePlayer.id,
       track: saveItemReference(track)
     })
   })
 
-  backend.on('clear-queue-up-to', (queuePlayer, track) => {
+  backend.on('QP: clear queue up to', (queuePlayer, track) => {
     client.sendCommand({
-      code: 'clear-queue-up-to',
+      code: 'clear queue up to',
       queuePlayer: queuePlayer.id,
       track: saveItemReference(track)
     })
   })
 
-  backend.on('distribute-queue', (queuePlayer, topItem, opts) => {
+  backend.on('QP: distribute queue', (queuePlayer, topItem, opts) => {
     client.sendCommand({
-      code: 'distribute-queue',
+      code: 'distribute queue',
       queuePlayer: queuePlayer.id,
       topItem: saveItemReference(topItem),
       opts
     })
   })
 
-  backend.on('done playing', queuePlayer => {
+  backend.on('QP: done playing', queuePlayer => {
     client.sendCommand({
       code: 'status',
-      status: 'done-playing',
+      status: 'done playing',
       queuePlayer: queuePlayer.id
     })
   })
 
-  backend.on('playing', (queuePlayer, track) => {
+  backend.on('QP: playing', (queuePlayer, track) => {
     if (track) {
       client.sendCommand({
         code: 'play',
@@ -888,19 +889,20 @@ function attachBackendToSocketClient(backend, client) {
       queuePlayer.once('received time data', data => {
         client.sendCommand({
           code: 'status',
-          status: 'ready-to-resume',
+          status: 'ready to resume',
           queuePlayer: queuePlayer.id
         })
       })
     } else {
       client.sendCommand({
-        code: 'stop-playing',
+        code: 'stop playing',
         queuePlayer: queuePlayer.id
       })
     }
   })
 
-  backend.on('queue', (queuePlayer, topItem, afterItem, opts) => {
+  let n = 0
+  backend.on('QP: queue', (queuePlayer, topItem, afterItem, opts) => {
     client.sendCommand({
       code: 'queue',
       queuePlayer: queuePlayer.id,
@@ -912,41 +914,41 @@ function attachBackendToSocketClient(backend, client) {
 
   function handleSeek(queuePlayer) {
     client.sendCommand({
-      code: 'seek-to',
+      code: 'seek to',
       queuePlayer: queuePlayer.id,
       time: queuePlayer.time
     })
   }
 
-  backend.on('seek-ahead', handleSeek)
-  backend.on('seek-back', handleSeek)
-  backend.on('seek-to', handleSeek)
+  backend.on('QP: seek ahead', handleSeek)
+  backend.on('QP: seek back', handleSeek)
+  backend.on('QP: seek to', handleSeek)
 
   backend.on('set party nickname', nickname => {
     let oldNickname = client.nickname
     sharedSources.name = namePartySources(nickname)
     client.nickname = nickname
-    client.sendCommand({code: 'set-nickname', nickname, oldNickname})
+    client.sendCommand({code: 'set nickname', nickname, oldNickname})
   })
 
-  backend.on('shuffle-queue', queuePlayer => {
+  backend.on('QP: shuffle queue', queuePlayer => {
     client.sendCommand({
-      code: 'restore-queue',
+      code: 'restore queue',
       why: 'shuffle',
       queuePlayer: queuePlayer.id,
       tracks: queuePlayer.queueGrouplike.items.map(saveItemReference)
     })
   })
 
-  backend.on('toggle-pause', queuePlayer => {
+  backend.on('QP: toggle pause', queuePlayer => {
     client.sendCommand({
-      code: 'set-pause',
+      code: 'set pause',
       queuePlayer: queuePlayer.id,
       paused: queuePlayer.player.isPaused
     })
   })
 
-  backend.on('unqueue', (queuePlayer, topItem) => {
+  backend.on('QP: unqueue', (queuePlayer, topItem) => {
     client.sendCommand({
       code: 'unqueue',
       queuePlayer: queuePlayer.id,
@@ -956,7 +958,7 @@ function attachBackendToSocketClient(backend, client) {
 
   backend.on('announce join party', () => {
     client.sendCommand({
-      code: 'announce-join'
+      code: 'announce join'
     })
   })
 
@@ -974,25 +976,17 @@ function attachBackendToSocketClient(backend, client) {
       updateRestoredTracksUsingPlaylists(backend, getPlaylistSources())
 
       client.sendCommand({
-        code: 'share-with-party',
+        code: 'share with party',
         item: serialized
       })
     }
   })
 }
 
-function attachSocketServerToBackend(server, backend) {
+export function attachSocketServerToBackend(server, backend) {
   // Unlike the function for attaching a backend to follow commands from a
   // client (attachBackendToSocketClient), this function is minimalistic.
   // It just sets the associated "canonical" backend. Actual logic for
   // de/serialization lives in serialized-backend.js.
   server.canonicalBackend = backend
 }
-
-Object.assign(module.exports, {
-  originalSymbol,
-  makeSocketServer,
-  makeSocketClient,
-  attachBackendToSocketClient,
-  attachSocketServerToBackend
-})