public async Task ConnectToCoreAsync(ICoreConnectionParams connectionParams) { EndPoint endPoint = connectionParams.EndPoint; if (CoreProxy != null) { Log.Error("Cannot connect to core, there is still a core proxy present"); throw new InvalidOperationException( "There is still a core proxy present"); } if (connectionParams.IsCoreLocal) { if (m_process == null) { await m_charmdRunner.StartIfNotRunningAndWaitAsync( Path.Combine(connectionParams.CoreProcessParams.WorkingDirectory, CharmdRelativePath), CharmdStartWaitMs); // TODO(HonzaS): Move this elsewhere when we have finer local process control. Log.Info("Starting a local core process"); m_process = m_coreProcessFactory.Create(connectionParams.CoreProcessParams); } endPoint = m_process.EndPoint; } if (endPoint == null) { Log.Error("Endpoint not set up, cannot connect to core"); throw new InvalidOperationException("Endpoint not set"); } m_isCoreLocal = connectionParams.IsCoreLocal; Log.Info("Connecting to Core running at {hostname:l}:{port}", endPoint.Hostname, endPoint.Port); ICoreLink coreLink = m_coreLinkFactory.Create(endPoint); // TODO(HonzaS): Check if the endpoint exists (handshake), await the response. // TODO(HonzaS): Move these inside the factory method. ICoreController coreController = m_coreControllerFactory.Create(coreLink); IModelUpdater modelUpdater = m_modelUpdaterFactory.Create(coreLink, coreController); CoreProxy = m_coreProxyFactory.Create(coreController, modelUpdater); RegisterCoreEvents(); }
public async Task ConnectToCoreAsync(ICoreConnectionParams connectionParams) { await Conductor.ConnectToCoreAsync(connectionParams); }