public void Execute()
        {
            ServerRunner.LogMessage("Executing adb command\n Activity : {0}\n AdbExeFilePath : {1}", this.Activity, this.AdbExeFile);

            var info = new ProcessStartInfo
            {
                FileName  = this.AdbExeFile,
                Arguments = this.BuildActivitylaunchCommand()
            };

            if (Environment.OSVersion.Platform.IsMacOSX())
            {
                info.UseShellExecute = false;                 // Mac OSX and Unix
            }
            else
            {
                info.UseShellExecute = true;                 // for Windows machines
            }
            ServerRunner.LogMessage($"arguments for adb: {info.Arguments}");

            using (var proc = Process.Start(info))
            {
                proc.WaitForExit();

                ServerRunner.LogMessage("Finished with adb command (return code : {0})", proc.ExitCode);
                this.ExitCode = proc.ExitCode;
            }
        }
        public bool Processing(TcpClient client)
        {
            string logfile = Path.Combine(this.@LogPath, this.LogFile ?? DateTime.UtcNow.Ticks + ".log");
            string remote  = client.Client.RemoteEndPoint.ToString();

            Console.WriteLine("Connection from {0} saving logs to {1}", remote, logfile);

            using (FileStream fs = File.OpenWrite(logfile))
            {
                string header = String.Format("[Local Date/Time:\t{1}]{0}[Remote Address:\t{2}]{0}",
                                              Environment.NewLine, DateTime.Now, remote);
                ServerRunner.LogMessage(header);

                int           i;
                int           total  = 0;
                NetworkStream stream = client.GetStream();

                while ((i = stream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    fs.Write(buffer, 0, i);
                    fs.Flush();
                    total += i;
                }

                if (total < 16)
                {
                    // This wasn't a test run, but a connection from the app (on device) to find
                    // the ip address we're reachable on.
                    return(false);
                }
            }

            return(true);
        }
        public void Initialize()
        {
            ServerRunner.LogMessage("User input for endpoint: {0}:{1}", this.Address, this.Port);

            this.server = new TcpListener(this.Address, this.Port);
            this.server.Start();

            if (this.Port == 0)
            {
                this.Port = ((IPEndPoint)this.server.LocalEndpoint).Port;
            }

            Console.WriteLine("Touch Server listening on: {0}:{1}", this.Address, this.Port);

            this.ExitCode = -1;
        }
        public void Execute()
        {
            ServerRunner.LogMessage("Executing adb command\n Command : {0}\n AdbExeFilePath : {1}", this.Activity, this.AdbExeFile);

            var info = new ProcessStartInfo
            {
                FileName        = this.AdbExeFile,
                UseShellExecute = true,
                Arguments       = this.BuildActivitylaunchCommand(),
            };

            using (var proc = new Process())
            {
                proc.StartInfo = info;

                proc.Start();
                proc.WaitForExit();

                ServerRunner.LogMessage("Finished with adb command (return code : {0})", proc.ExitCode);
                this.ExitCode = proc.ExitCode;
            }
        }