private void WriteToClient(NamedPipeMessages.UnregisterRepoRequest.Response response) { NamedPipeMessages.Message message = response.ToMessage(); if (!this.connection.TrySendResponse(message)) { this.tracer.RelatedError("Failed to send line to client: {0}", message); } }
private bool UnregisterRepo(string rootPath, out string errorMessage) { errorMessage = string.Empty; NamedPipeMessages.UnregisterRepoRequest request = new NamedPipeMessages.UnregisterRepoRequest(); request.EnlistmentRoot = rootPath; using (NamedPipeClient client = new NamedPipeClient(this.ServicePipeName)) { if (!client.Connect()) { errorMessage = "Unable to unregister repo because GVFS.Service is not responding. " + GVFSVerb.StartServiceInstructions; return(false); } try { client.SendRequest(request.ToMessage()); NamedPipeMessages.Message response = client.ReadResponse(); if (response.Header == NamedPipeMessages.UnregisterRepoRequest.Response.Header) { NamedPipeMessages.UnregisterRepoRequest.Response message = NamedPipeMessages.UnregisterRepoRequest.Response.FromMessage(response); if (message.State != NamedPipeMessages.CompletionState.Success) { errorMessage = message.ErrorMessage; return(false); } else { errorMessage = string.Empty; return(true); } } else { errorMessage = string.Format("GVFS.Service responded with unexpected message: {0}", response); return(false); } } catch (BrokenPipeException e) { errorMessage = "Unable to communicate with GVFS.Service: " + e.ToString(); return(false); } } }
public void Run() { string errorMessage = string.Empty; NamedPipeMessages.UnregisterRepoRequest.Response response = new NamedPipeMessages.UnregisterRepoRequest.Response(); if (this.registry.TryDeactivateRepo(this.request.EnlistmentRoot, out errorMessage)) { response.State = NamedPipeMessages.CompletionState.Success; } else { response.ErrorMessage = errorMessage; response.State = NamedPipeMessages.CompletionState.Failure; } this.WriteToClient(response); }
public void Run() { string errorMessage = string.Empty; NamedPipeMessages.UnregisterRepoRequest.Response response = new NamedPipeMessages.UnregisterRepoRequest.Response(); if (this.registry.TryDeactivateRepo(this.request.EnlistmentRoot, out errorMessage)) { response.State = NamedPipeMessages.CompletionState.Success; this.tracer.RelatedInfo("Deactivated repo {0}", this.request.EnlistmentRoot); } else { response.ErrorMessage = errorMessage; response.State = NamedPipeMessages.CompletionState.Failure; this.tracer.RelatedError("Failed to deactivate repo {0} with error: {1}", this.request.EnlistmentRoot, errorMessage); } this.WriteToClient(response.ToMessage(), this.connection, this.tracer); }