/// <see cref="IWDClientServices.StartRemoteStreamingSink"></see> async Task IWDClientServices.StartRemoteStreamingSink(string streamType, UInt16 port, string streamScreenResolution) { // First stop eventually running remote streaming-sink await((IWDClientServices)this).StopRemoteStreamingSink(); string sinkScreenResolution = await ((IWDClientServices)this).GetCurrentRemoteScreenResolution(); string scriptArgs = _scriptArgsStartStreamingSink; scriptArgs = scriptArgs.Replace(MagicStrings.PLACEHOLDER_STREAMING_TYPE, streamType); scriptArgs = scriptArgs.Replace(MagicStrings.PLACEHOLDER_SOURCE_IP, _localIpAddress); scriptArgs = scriptArgs.Replace(MagicStrings.PLACEHOLDER_PORT, port.ToString()); scriptArgs = scriptArgs.Replace(MagicStrings.PLACEHOLDER_SINK_SCREEN_RESOLUTION, sinkScreenResolution); scriptArgs = scriptArgs.Replace(MagicStrings.PLACEHOLDER_STREAM_SCREEN_RESOLUTION, streamScreenResolution); // Exceptions have to be handled by the caller. // Store the process-ID of the started process in _processIdStreamingSink _processIdStreamingSink = await _remoteScriptRunner.StartScript( _scriptNameStartStreamingSink, scriptArgs); _logger?.LogInformation($"Started remote streaming-sink of type '{streamType}', listening on port {port}. Process-Id={_processIdStreamingSink}."); }
public async Task StartQueryAndStopScript_NormalUsecase_everythingOk() { // Start script int processId = await _scriptRunner.StartScript( scriptName : TEST_SCRIPT_FOR_START_STOP, scriptArgs : string.Join(" ", TEST_SCRIPT_ARGS), stdin : TEST_SCRIPT_STDIN ); Assert.NotZero(processId); System.Diagnostics.Debug.Write("Waiting 11 seconds"); for (int i = 0; i < 11; i++) { System.Threading.Thread.Sleep(1000); System.Diagnostics.Debug.Write("."); } // Query, if script is still running bool isRunning = await _scriptRunner.IsScriptRunning(processId); Assert.True(isRunning); // Stop script (int exitCode, List <string> stdoutLines, List <string> stderrLines) = await _scriptRunner.StopScript(processId); // Exit code is not 5, because "sleep"-command is killed and produces an // exit-codes like 137. Assert.NotZero(exitCode); // The following assertions only appy, if "LetShellWindowsPopUpWhenStartScript" // in config.json of the ScritingRestApiServer is set to "false", so leave them // commented out generally: // The testscript writes the first two arguments to stdout //Assert.AreEqual( stdoutLines[0], TEST_SCRIPT_ARGS[0]); //Assert.AreEqual( stdoutLines[1], TEST_SCRIPT_ARGS[1]); // The testsript writes the third and fourth argument to stderr //Assert.AreEqual( stderrLines[0], TEST_SCRIPT_ARGS[2]); //Assert.AreEqual( stderrLines[1], TEST_SCRIPT_ARGS[3]); }