Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert AgentHub to use strongly-typed clients. #702

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent/Interfaces/IAppLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public interface IAppLauncher
{
Task<int> LaunchChatService(string pipeName, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection);
Task LaunchRemoteControl(int targetSessionId, string sessionId, string accessKey, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection);
Task RestartScreenCaster(List<string> viewerIDs, string sessionId, string accessKey, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection, int targetSessionID = -1);
Task RestartScreenCaster(string[] viewerIds, string sessionId, string accessKey, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection, int targetSessionID = -1);
}
20 changes: 11 additions & 9 deletions Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private static async Task Init(IServiceProvider services)
{
SetSas(services, logger);
}

// TODO: Move this to a BackgroundService.
await services.GetRequiredService<IUpdater>().BeginChecking();
await services.GetRequiredService<IAgentHubConnection>().Connect();
}
Expand All @@ -91,34 +93,34 @@ private static void RegisterServices(IServiceCollection services)
services.AddSingleton<ICpuUtilizationSampler, CpuUtilizationSampler>();
services.AddSingleton<IWakeOnLanService, WakeOnLanService>();
services.AddHostedService(services => services.GetRequiredService<ICpuUtilizationSampler>());
services.AddScoped<IChatClientService, ChatClientService>();
services.AddSingleton<IChatClientService, ChatClientService>();
services.AddTransient<IPsCoreShell, PsCoreShell>();
services.AddTransient<IExternalScriptingShell, ExternalScriptingShell>();
services.AddScoped<IConfigService, ConfigService>();
services.AddScoped<IUninstaller, Uninstaller>();
services.AddScoped<IScriptExecutor, ScriptExecutor>();
services.AddScoped<IProcessInvoker, ProcessInvoker>();
services.AddScoped<IUpdateDownloader, UpdateDownloader>();
services.AddSingleton<IConfigService, ConfigService>();
services.AddSingleton<IUninstaller, Uninstaller>();
services.AddSingleton<IScriptExecutor, ScriptExecutor>();
services.AddSingleton<IProcessInvoker, ProcessInvoker>();
services.AddSingleton<IUpdateDownloader, UpdateDownloader>();
services.AddSingleton<IFileLogsManager, FileLogsManager>();
services.AddSingleton<IScriptingShellFactory, ScriptingShellFactory>();

if (OperatingSystem.IsWindows())
{
services.AddScoped<IAppLauncher, AppLauncherWin>();
services.AddSingleton<IAppLauncher, AppLauncherWin>();
services.AddSingleton<IUpdater, UpdaterWin>();
services.AddSingleton<IDeviceInformationService, DeviceInfoGeneratorWin>();
services.AddSingleton<IElevationDetector, ElevationDetectorWin>();
}
else if (OperatingSystem.IsLinux())
{
services.AddScoped<IAppLauncher, AppLauncherLinux>();
services.AddSingleton<IAppLauncher, AppLauncherLinux>();
services.AddSingleton<IUpdater, UpdaterLinux>();
services.AddSingleton<IDeviceInformationService, DeviceInfoGeneratorLinux>();
services.AddSingleton<IElevationDetector, ElevationDetectorLinux>();
}
else if (OperatingSystem.IsMacOS())
{
services.AddScoped<IAppLauncher, AppLauncherMac>();
services.AddSingleton<IAppLauncher, AppLauncherMac>();
services.AddSingleton<IUpdater, UpdaterMac>();
services.AddSingleton<IDeviceInformationService, DeviceInfoGeneratorMac>();
}
Expand Down