Skip to content

Commit

Permalink
feature (shell/dotnet): Add fdc3 object
Browse files Browse the repository at this point in the history
Added fdc3 object to ServiceCollection
Create the "default" UserChannel on startup
  • Loading branch information
ZKRobi committed Jun 23, 2023
1 parent 1742e8a commit df58e0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/shell/dotnet/Shell.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shell.Tests", "tests\Shell.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Messaging.Host", "..\..\messaging\dotnet\src\Host\MorganStanley.ComposeUI.Messaging.Host.csproj", "{DD91C297-06D4-4578-9C75-1BA5D8595AA0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopAgent", "..\..\fdc3\dotnet\DesktopAgent\src\DesktopAgent\DesktopAgent.csproj", "{7A94BC15-8FE5-4C84-8572-3C72248AFF8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -43,6 +45,10 @@ Global
{DD91C297-06D4-4578-9C75-1BA5D8595AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD91C297-06D4-4578-9C75-1BA5D8595AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD91C297-06D4-4578-9C75-1BA5D8595AA0}.Release|Any CPU.Build.0 = Release|Any CPU
{7A94BC15-8FE5-4C84-8572-3C72248AFF8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A94BC15-8FE5-4C84-8572-3C72248AFF8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A94BC15-8FE5-4C84-8572-3C72248AFF8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A94BC15-8FE5-4C84-8572-3C72248AFF8C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -52,6 +58,7 @@ Global
{F0DFAB55-14F5-4FF6-A12F-37B1745D4551} = {E7A2C581-4BF4-47A5-8A11-59B2DEBADCA7}
{70491F36-A27B-4E8C-AFD5-B49480EC1343} = {BEA71FE5-7EC8-4BEA-819B-C0DB33125D91}
{DD91C297-06D4-4578-9C75-1BA5D8595AA0} = {E7A2C581-4BF4-47A5-8A11-59B2DEBADCA7}
{7A94BC15-8FE5-4C84-8572-3C72248AFF8C} = {E7A2C581-4BF4-47A5-8A11-59B2DEBADCA7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C901E6C-4B9A-48C2-AB16-461040DC57B4}
Expand Down
14 changes: 9 additions & 5 deletions src/shell/dotnet/Shell/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using MorganStanley.ComposeUI.Fdc3.DesktopAgent;
using MorganStanley.ComposeUI.Messaging.Server.WebSocket;
using Shell.Utilities;

Expand All @@ -32,13 +33,13 @@ namespace Shell;
/// </summary>
public partial class App : Application
{
public new static App Current => (App)Application.Current;
public new static App Current => (App) Application.Current;

public IHost Host =>
_host
?? throw new InvalidOperationException(
"Attempted to access the Host object before async startup has completed");

/// <summary>
/// Creates a new window of the specified type. Constructor arguments that are not registered in DI can be provided.
/// </summary>
Expand Down Expand Up @@ -85,8 +86,9 @@ private async Task StartAsync(StartupEventArgs e)
await host.StartAsync();
_host = host;
_logger = _host.Services.GetRequiredService<ILogger<App>>();

await OnHostInitializedAsync();

Dispatcher.Invoke(() => OnAsyncStartupCompleted(e));
}

Expand All @@ -102,13 +104,16 @@ private void ConfigureServices(HostBuilderContext context, IServiceCollection se
// TODO: Assign a separate token for each client and only allow a single connection with each token
if (_messageRouterAccessToken != token)
throw new InvalidOperationException("The provided access token is invalid");
} ));
}));

services.AddMessageRouter(
mr => mr
.UseServer()
.UseAccessToken(_messageRouterAccessToken));


services.AddFdc3DesktopAgent(fdc3 => fdc3.WithUserChannel("default"));

services.Configure<LoggerFactoryOptions>(context.Configuration.GetSection("Logging"));
}

Expand Down Expand Up @@ -171,4 +176,3 @@ private void InjectMessageRouterConfig()
""");
}
}

1 change: 1 addition & 0 deletions src/shell/dotnet/Shell/Shell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\fdc3\dotnet\DesktopAgent\src\DesktopAgent\DesktopAgent.csproj" />
<ProjectReference Include="..\..\..\messaging\dotnet\src\Host\MorganStanley.ComposeUI.Messaging.Host.csproj" />
</ItemGroup>

Expand Down

0 comments on commit df58e0c

Please sign in to comment.