Ejemplo n.º 1
0
 public void Terminate()
 {
     if (!_onResumeCalled)
     {
         Telemetry.SendLaunchError(Telemetry.LaunchFailureCode.LaunchFailure.ToString(), _launchOptions.IOSDebugTarget);
     }
     //Nothing to do for this.
 }
Ejemplo n.º 2
0
        public string GetRemoteAppPath()
        {
            string appPath  = string.Empty;
            var    response = CallVcRemote(new Uri("debug/appRemotePath?package=" + _launchOptions.PackageId + "&deviceUdid=" + _launchOptions.DeviceUdid, UriKind.Relative), LauncherResources.Info_GettingInfo, out appPath);

            if (string.IsNullOrWhiteSpace(appPath))
            {
                Telemetry.SendLaunchError(Telemetry.LaunchFailureCode.BadPackageId.ToString(), _launchOptions.IOSDebugTarget);
                Debug.Fail("Invalid return from vcremote for packageId");
                throw new InvalidOperationException();
            }

            return(appPath);
        }
Ejemplo n.º 3
0
        public Launcher.RemotePorts StartDebugListener()
        {
            string remotePortsJsonString;

            CallVcRemote(new Uri("debug/setupForDebugging?target=" + _launchOptions.IOSDebugTarget.ToString() + "&deviceUdid=" + _launchOptions.DeviceUdid, UriKind.Relative), LauncherResources.Info_StartingDebugListener, out remotePortsJsonString);

            try
            {
                return(JsonConvert.DeserializeObject <Launcher.RemotePorts>(remotePortsJsonString));
            }
            catch (JsonException)
            {
                Telemetry.SendLaunchError(Telemetry.LaunchFailureCode.BadJson.ToString(), _launchOptions.IOSDebugTarget);
                throw new LauncherException(LauncherResources.Error_BadJSon);
            }
        }
Ejemplo n.º 4
0
        private HttpResponseMessage CallVcRemote(Uri endpoint, string waitLoopMessage, out string responseBody)
        {
            ManualResetEvent        doneEvent = new ManualResetEvent(false);
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            var waitLoop = new MICore.WaitLoop(waitLoopMessage);
            ExceptionDispatchInfo exceptionDispatchInfo = null;

            HttpResponseMessage response = null;
            string content = null;

            ThreadPool.QueueUserWorkItem(async(object o) =>
            {
                string failureCode = Telemetry.VcRemoteFailureCode.VcRemoteSucces.ToString();

                try
                {
                    response = await this.GetAsync(endpoint, cancellationTokenSource.Token);
                    response.EnsureSuccessStatusCode();

                    content = await response.Content.ReadAsStringAsync();
                }
                catch (HttpRequestException)
                {
                    if (response != null)
                    {
                        if (response.StatusCode == HttpStatusCode.Unauthorized)
                        {
                            exceptionDispatchInfo = ExceptionDispatchInfo.Capture(new LauncherException(LauncherResources.Error_Unauthorized));
                            failureCode           = Telemetry.VcRemoteFailureCode.VcRemoteUnauthorized.ToString();
                        }
                        else
                        {
                            exceptionDispatchInfo = ExceptionDispatchInfo.Capture(new LauncherException(string.Format(LauncherResources.Error_VcRemoteUnknown, response.StatusCode.ToString())));
                            failureCode           = Telemetry.VcRemoteFailureCode.VcRemoteUnkown.ToString();
                        }
                    }
                    else
                    {
                        exceptionDispatchInfo = ExceptionDispatchInfo.Capture(new LauncherException(LauncherResources.Error_UnableToReachServer));
                        failureCode           = Telemetry.VcRemoteFailureCode.VcRemoteNoConnection.ToString();
                    }
                }
                catch (TaskCanceledException)
                {
                    //timeout
                    exceptionDispatchInfo = ExceptionDispatchInfo.Capture(new LauncherException(LauncherResources.Error_UnableToReachServer));
                    failureCode           = Telemetry.VcRemoteFailureCode.VcRemoteNoConnection.ToString();
                }
                catch (Exception e)
                {
                    exceptionDispatchInfo = ExceptionDispatchInfo.Capture(e);
                    failureCode           = e.GetType().FullName;
                }

                doneEvent.Set();

                Telemetry.SendLaunchError(failureCode, _launchOptions.IOSDebugTarget);
            });

            waitLoop.Wait(doneEvent, cancellationTokenSource);

            if (exceptionDispatchInfo != null)
            {
                exceptionDispatchInfo.Throw();
            }

            if (response == null)
            {
                Debug.Fail("Null resposne? Should be impossible.");
                throw new InvalidOperationException();
            }

            responseBody = content;
            return(response);
        }
Ejemplo n.º 5
0
 void IPlatformAppLauncher.OnResume()
 {
     _onResumeCalled = true;
     Telemetry.SendLaunchError(Telemetry.LaunchFailureCode.LaunchSuccess.ToString(), _launchOptions.IOSDebugTarget);
     //Nothing to do for this.
 }