Skip to content

Commit

Permalink
Merge pull request #702 from immense/tech/strongly-typed-hub-clients
Browse files Browse the repository at this point in the history
Convert AgentHub to use strongly-typed clients.
  • Loading branch information
bitbound authored Aug 4, 2023
2 parents f0e6f81 + 33d4384 commit 75a2a56
Show file tree
Hide file tree
Showing 19 changed files with 633 additions and 432 deletions.
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
Loading

0 comments on commit 75a2a56

Please sign in to comment.