public RemoteDeploymentManager(string serviceUrl) { serviceUrl = UrlUtility.EnsureTrailingSlash(serviceUrl); _client = HttpClientHelper.Create(serviceUrl); // Raise the event when data comes in _connection = new Connection(serviceUrl + "status"); _connection.Received += data => { if (StatusChanged != null) { var result = JsonConvert.DeserializeObject<DeployResult>(data); StatusChanged(result); } }; _connection.Error += exception => { // If we get a 404 back stop listening for changes WebException webException = exception as WebException; if (webException != null) { var webResponse = (HttpWebResponse)webException.Response; if (webResponse != null && webResponse.StatusCode == HttpStatusCode.NotFound) { _connection.Stop(); } } }; _connection.Closed += () => { Debug.WriteLine("SignalR connection to {0} was closed.", serviceUrl); }; _connection.Start().Wait(); }