diff --git a/LaunchScript/VirtualAcousticsStarterServer.py b/LaunchScript/VirtualAcousticsStarterServer.py index e5b5acb0b95458f5d74db0e1e76e7f9674890ea6..21baed9b6bea72089b9def072980861c29d263dc 100644 --- a/LaunchScript/VirtualAcousticsStarterServer.py +++ b/LaunchScript/VirtualAcousticsStarterServer.py @@ -32,9 +32,9 @@ class LauncherConfig: sys.exit( ErrorCodes.ERROR_INCOMPLETE_CONFIG ) class VAComposedIniParser: - def __init__(self, lsReproductionModuleIDs, sRendererIniPath = None): + def __init__(self, lsReproductionModuleIDs): self.lsReproductionModuleIDs = lsReproductionModuleIDs - self.sRendererIniPath = sRendererIniPath + self.sRendererIniPath = None self.sConfFolder = "../conf/" def _create_parser(self): @@ -163,6 +163,7 @@ class VirtualAcousticsLauncher: self.oLauncherConnection = None self.sVAServerDir = None self.sVAServerID = None + self.vaIniParser.sRendererIniPath = None def _close_va_and_reset_connection(self): if self.oVAProcess: @@ -175,9 +176,6 @@ class VirtualAcousticsLauncher: def main_loop(self): try: - #TODO-PSC: Receive file and name from client - self.vaIniParser.sRendererIniPath = None - self.vaIniParser.prepare_inis() while True: if not self.oLauncherConnection: self.wait_for_connection() @@ -217,15 +215,23 @@ class VirtualAcousticsLauncher: self.oVAProcess.kill() self.oVAProcess = None - self.receive_va_server_id() + self.receive_va_start_info() + self.vaIniParser.prepare_inis() #Checks for a message containing the ID of the VAServer instance to be started and returns the respective VAServer directory - def receive_va_server_id(self): + def receive_va_start_info(self): try: - self.sVAServerID = self.oLauncherConnection.recv( 512 ) - if type( self.sVAServerID ) is bytes: - self.sVAServerID = self.sVAServerID.decode( 'utf-8' ) + sMessage = self.oLauncherConnection.recv( 512 ) + if type( sMessage ) is bytes: + sMessage = sMessage.decode( 'utf-8' ) + + if ":" not in sMessage: #VAServer ID, should be received last + self.sVAServerID = sMessage + else: #VARenderer.ini file, optional + self.vaIniParser.sRendererIniPath = self.receive_file(sMessage) + return self.receive_va_start_info() + print( "Received launch request for variant: " + self.sVAServerID ) except socket.error: print( "Error while reading variant" ) @@ -305,7 +311,7 @@ class VirtualAcousticsLauncher: if sMessage.startswith("file"): self.receive_file(sMessage) else: #NOT sMessage.startswith("file") - print( "Received quit event: "+sMessage ) + print( "Received quit event: " + sMessage ) self._close_va_and_reset_connection() break @@ -319,6 +325,8 @@ class VirtualAcousticsLauncher: raise #re-raise for higher instance to catch + # Receives a file from a client, copies it to a tmp folder and returns the respective fullpath + # Input is a string message starting with "file:" def receive_file(self, sMessage): aMessageParts = sMessage.split(":") iBytesToReceive = int(aMessageParts[2]) @@ -367,6 +375,8 @@ class VirtualAcousticsLauncher: self.oLauncherConnection.send( b'fail' ) #send failure print("File receive failed") + return Fullpath+Filename + #create an instance of the class