private bool WaitForOtherInstance() { Timing t = Timing.StartNew(); while (t.Elapsed < TimeSpan.FromSeconds(20)) { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (ipcRemotingService.TryCreateServer(id)) { Log.Debug("Other instance has closed"); return(true); } } } catch (Exception e) { Log.Exception(e, "Failed to check if other instance is running"); } Thread.Sleep(100); } Log.Error("Failed to wait for other instance"); return(false); }
private static void HandleAskPasswordRequest(string promptText) { string sessionId = Environment.GetEnvironmentVariable("GITMIND_SESSIONID"); Log.Debug($"Ask Pass session {sessionId} prompt: '{promptText}'"); // Sending the request to the "original" GitMind instance that made the git call using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { // Make the call to the CredentialIpcService string response = ipcRemotingService.CallService <CredentialIpcService, string>( sessionId, service => service.AskPassRequest(promptText)); if (response == null) { Log.Debug("Response: null, Canceled"); Console.Out.Close(); return; } if (!string.IsNullOrEmpty(response)) { Log.Debug("Response: ******"); // Return the response to the calling git.exe process Console.Write(response); } else { Log.Debug("No Response:"); } } }
private bool IsActivatedOtherInstance() { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (!ipcRemotingService.TryCreateServer(id)) { // Another GitMind instance for that working folder is already running, activate that. Log.Debug("Try activate other instance ..."); var args = Environment.GetCommandLineArgs(); ipcRemotingService.CallService <MainWindowIpcService>(id, service => service.Activate(args)); Track.Event("ActivatedOtherInstance"); return(true); } else { Log.Debug("Continue with this instance..."); } } } catch (Exception e) { Log.Exception(e, "Failed to activate other instance"); } return(false); }
private void StartIpcServerSide() { // Start IPC server side, which can receive requests from a tmp GitMind process started by // git, when git requires credentials via the GIT_ASKPASS environment vartiable serverSideIpcService = new IpcRemotingService(); serverSideIpcService.TryCreateServer(SessionId); serverSideIpcService.PublishService(new CredentialIpcService(this)); }
public void TestIfNoServer() { string id = Guid.NewGuid().ToString(); using (IpcRemotingService ipcClientService = new IpcRemotingService()) { string request = "Some request text"; Assert.Throws <RemotingException>(() => ipcClientService.CallService <ServerSide, string>( id, service => service.DoubleText(request))); } }
public void Test() { string id = Guid.NewGuid().ToString(); using (IpcRemotingService ipcServerService = new IpcRemotingService()) { Assert.IsTrue(ipcServerService.TryCreateServer(id)); ipcServerService.PublishService(new ServerSide()); using (IpcRemotingService ipcClientService = new IpcRemotingService()) { string request = "Some request text"; string response = ipcClientService.CallService <ServerSide, string>( id, service => service.DoubleText(request)); Assert.AreEqual(request + request, response); } } }
public bool IsActivatedOtherInstance(string workingFolder) { try { string id = MainWindowIpcService.GetId(workingFolder); using (IpcRemotingService ipcRemotingService = new IpcRemotingService()) { if (!ipcRemotingService.TryCreateServer(id)) { // Another GitMind instance for that working folder is already running, activate that. var args = Environment.GetCommandLineArgs(); ipcRemotingService.CallService <MainWindowIpcService>(id, service => service.Activate(args)); return(true); } } } catch (Exception e) { Log.Warn($"Failed to activate other instance {e}"); } return(false); }
public void Dispose() { serverSideIpcService?.Dispose(); serverSideIpcService = null; }