Esempio n. 1
0
        internal Process SetupProxy(ConnectedDevice device)
        {
            var currentDir = $"{Environment.GetEnvironmentVariable("SiliconStudioXenkoDir")}\\Bin\\Windows-Direct3D11\\";
            var iosId      = Path.Combine(currentDir, "iproxy.exe");

            int testedLocalPort;

            do
            {
                testedLocalPort = startLocalPort++;
                if (startLocalPort >= 65536) // Make sure we stay in the range of dynamic ports: 49152-65535
                {
                    startLocalPort = 49152;
                }
            } while (!CheckAvailableServerPort(testedLocalPort));

            Task.Run(async() =>
            {
                while (!device.DeviceDisconnected)
                {
                    try
                    {
                        await router.TryConnect("localhost", testedLocalPort);
                    }
                    catch (Exception)
                    {
                        // Mute exceptions and try to connect again
                        // TODO: Mute connection only, not message loop?
                    }

                    await Task.Delay(200);
                }
            });

            var process = new Process
            {
                StartInfo =
                {
                    UseShellExecute  = false,
                    CreateNoWindow   = true,
                    WorkingDirectory = currentDir,
                    FileName         = iosId,
                    Arguments        = $"{testedLocalPort} {RouterClient.DefaultListenPort} {device.Name}"
                }
            };

            process.Start();
            new AttachedChildProcessJob(process);

            Log.Info("iOS Device connected: {0}; successfully mapped port {1}:{2}", device.Name, testedLocalPort, RouterClient.DefaultListenPort);

            return(process);
        }
Esempio n. 2
0
        public static async Task LaunchPersistentClient(ConnectedDevice connectedDevice, Router router, string address, int localPort)
        {
            while (!connectedDevice.DeviceDisconnected)
            {
                try
                {
                    await router.TryConnect(address, localPort);
                }
                catch (Exception)
                {
                    // Mute exceptions and try to connect again
                    // TODO: Mute connection only, not message loop?
                }

                await Task.Delay(200);
            }
        }