public async Task <bool> OnPluginConnected(IImportPluginService pluginSvc, string channelName) { if (pluginSvc == null) { return(false); } using (await _pluginSvcLock.LockAsync()) { try { var resp = pluginSvc.ConnectBrowser(_extensionId, _userAgent, channelName); if (resp == null) { LogTo.Warning($"{_extensionId} failed to connect to Plugin"); return(false); } LogTo.Debug($"Connected to plugin, version {resp.Version}"); await _host.Write(resp); PluginSvc = pluginSvc; return(true); } catch (EndOfStreamException) { } return(false); } }
public async Task OnPluginDisconnected() { using (await _pluginSvcLock.LockAsync()) if (PluginSvc != null) { PluginSvc = null; try { await _host.Write(new RespDisconnect()); } catch (EndOfStreamException) { } } _ipcService.OnDisconnected().RunAsync(); }
private async Task KeepAlive(IImportPluginService pluginSvc) { try { while (true) { pluginSvc.KeepAlive(); await Task.Delay(RetryDelayMs); } } catch (RemotingException) { await _hostService.OnPluginDisconnected(); } catch (Exception ex) { LogTo.Error(ex, "Exception caught in KeepAlive"); throw; } }