Skip to content

Commit e453bb5

Browse files
StiggimyCopilot
authored andcommitted
Migrate to ActualLab.Rpc + Fix DLL Hell (ConnectionReset)
1 parent 29a6305 commit e453bb5

File tree

6 files changed

+59
-47
lines changed

6 files changed

+59
-47
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ BenchmarkDotNet.Artifacts/
5757

5858
# .NET Core
5959
project.lock.json
60+
RelayTestServer/
6061
project.fragment.lock.json
6162
artifacts/
63+
publish_ms_out/
64+
publish_out/
65+
*.zip
6266

6367
# StyleCop
6468
StyleCopReport.xml

plugin_Relay.sln

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,42 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
.editorconfig = .editorconfig
1111
EndProjectSection
1212
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RelayTestServer", "RelayTestServer\RelayTestServer.csproj", "{91A955FC-0A91-4DD9-80A4-B0E79205B357}"
14+
EndProject
1315
Global
1416
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1517
Debug|x64 = Debug|x64
18+
Debug|Any CPU = Debug|Any CPU
19+
Debug|x86 = Debug|x86
1620
Release|x64 = Release|x64
21+
Release|Any CPU = Release|Any CPU
22+
Release|x86 = Release|x86
1723
EndGlobalSection
1824
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1925
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|x64.ActiveCfg = Debug|x64
2026
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|x64.Build.0 = Debug|x64
27+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|x86.ActiveCfg = Debug|Any CPU
30+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Debug|x86.Build.0 = Debug|Any CPU
2131
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|x64.ActiveCfg = Release|x64
2232
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|x64.Build.0 = Release|x64
33+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|x86.ActiveCfg = Release|Any CPU
36+
{3C5DB9DE-D479-4160-815D-7B664F6AC8EF}.Release|x86.Build.0 = Release|Any CPU
37+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|x64.ActiveCfg = Debug|Any CPU
38+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|x64.Build.0 = Debug|Any CPU
39+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Debug|x86.Build.0 = Debug|Any CPU
43+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|x64.ActiveCfg = Release|Any CPU
44+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|x64.Build.0 = Release|Any CPU
45+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|x86.ActiveCfg = Release|Any CPU
48+
{91A955FC-0A91-4DD9-80A4-B0E79205B357}.Release|x86.Build.0 = Release|Any CPU
2349
EndGlobalSection
2450
GlobalSection(SolutionProperties) = preSolution
2551
HideSolutionNode = FALSE

plugin_Relay/Models/Contract.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Amethyst.Plugins.Contract;
77
using MemoryPack;
88
using Microsoft.Extensions.Logging;
9-
using Stl.Rpc;
9+
using ActualLab.Rpc;
1010

1111
namespace plugin_Relay.Models;
1212

plugin_Relay/RelayDevice.cs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using plugin_Relay.Models;
1717
using plugin_Relay.Pages;
1818
using Microsoft.Extensions.Logging;
19-
using Stl.Rpc;
19+
using ActualLab.Rpc;
2020

2121
// To learn more about WinUI, the WinUI project structure,
2222
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -169,39 +169,29 @@ public void Initialize()
169169
// Mark as initialized
170170
IsInitialized = true;
171171

172-
try
173-
{
174-
MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter());
175-
MemoryPackFormatterProvider.Register(new TrackedJointFormatter());
172+
MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter());
173+
MemoryPackFormatterProvider.Register(new TrackedJointFormatter());
176174

177-
if (RelayService.Instance?.IsBackfeed ?? false)
178-
{
179-
Status = RelayDeviceStatus.BackFeedDetected;
180-
SettingsPage.DeviceStatusAppendix = string.Empty;
181-
InitException = null;
182-
return; // Don't proceed further
183-
}
175+
if (RelayService.Instance?.IsBackfeed ?? false)
176+
{
177+
Status = RelayDeviceStatus.BackFeedDetected;
178+
SettingsPage.DeviceStatusAppendix = string.Empty;
179+
InitException = null;
180+
return; // Don't proceed further
181+
}
184182

185-
var services = new ServiceCollection()
186-
.AddLogging(logging => logging.AddConsole());
183+
var services = new ServiceCollection()
184+
.AddLogging();
187185

188-
services.AddRpc()
189-
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
190-
.AddClient<IRelayService>()
191-
.AddServer<IRelayClient, DataClient>();
186+
services.AddRpc()
187+
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
188+
.AddClient<IRelayService>();
192189

193-
ServiceChannel = services.BuildServiceProvider();
194-
Service = ServiceChannel.GetRequiredService<IRelayService>();
190+
ServiceChannel = services.BuildServiceProvider();
191+
Service = ServiceChannel.GetRequiredService<IRelayService>();
195192

196-
SettingsPage.DeviceStatusAppendix = string.Empty;
197-
SettingsPage.StartConnectionTest();
198-
}
199-
catch (Exception ex)
200-
{
201-
InitException = ex;
202-
Status = RelayDeviceStatus.ServiceError;
203-
return;
204-
}
193+
SettingsPage.DeviceStatusAppendix = string.Empty;
194+
SettingsPage.StartConnectionTest();
205195

206196
Host.Log($"Tried to initialize with status: {DeviceStatusString}");
207197
InitException = null;

plugin_Relay/RelayService.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
using Microsoft.UI.Xaml;
1616
using Microsoft.UI.Xaml.Controls;
1717
using plugin_Relay.Models;
18-
using Stl.Rpc;
18+
using ActualLab.Rpc;
1919
using IServiceEndpoint = Amethyst.Plugins.Contract.IServiceEndpoint;
2020
using Microsoft.AspNetCore.Builder;
21-
using Stl.Rpc.Server;
21+
using ActualLab.Rpc.Server;
2222
using MemoryPack;
2323
using Microsoft.Extensions.Logging;
2424

@@ -209,18 +209,6 @@ public int Initialize()
209209
rpc.AddServer<IRelayService, DataService>()
210210
.AddClient<IRelayClient>();
211211

212-
builder.Services.AddSingleton<RpcCallRouter>(c =>
213-
{
214-
RpcHub rpcHub = null; // Necessary because of IRelayClient, which requires call routing
215-
return (methodDef, args) =>
216-
{
217-
rpcHub ??= c.RpcHub(); // We can't resolve it earlier, coz otherwise it will trigger recursion
218-
if (methodDef.Service.Type != typeof(IRelayClient)) return rpcHub.GetClientPeer(RpcPeerRef.Default);
219-
var peerRef = new RpcPeerRef(args.Get<Stl.Text.Symbol>(0), true);
220-
return rpcHub.GetServerPeer(peerRef);
221-
};
222-
});
223-
224212
var app = builder.Build();
225213
app.Urls.Add($"http://0.0.0.0:{ServerPort}/");
226214
app.UseWebSockets();

plugin_Relay/plugin_Relay.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27+
<PackageReference Include="ActualLab.Generators" Version="12.1.51">
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
29+
<PrivateAssets>all</PrivateAssets>
30+
</PackageReference>
31+
<PackageReference Include="ActualLab.Rpc" Version="12.1.51" />
32+
<PackageReference Include="ActualLab.Rpc.Server" Version="12.1.51" />
2733
<PackageReference Include="Amethyst.Plugins.Contract" Version="1.3.0" />
2834
<PackageReference Include="MemoryPack" Version="1.21.4" />
2935
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
3036
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
31-
<PackageReference Include="Stl.Generators" Version="6.8.11" />
32-
<PackageReference Include="Stl.Rpc" Version="6.8.11" />
33-
<PackageReference Include="Stl.Rpc.Server" Version="6.8.11" />
37+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
3438
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
3539
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="8.0.0" />
3640
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />

0 commit comments

Comments
 (0)