|
16 | 16 | using plugin_Relay.Models; |
17 | 17 | using plugin_Relay.Pages; |
18 | 18 | using Microsoft.Extensions.Logging; |
19 | | -using ActualLab.Rpc; |
| 19 | +using Stl.Rpc; |
20 | 20 |
|
21 | 21 | // To learn more about WinUI, the WinUI project structure, |
22 | 22 | // and more about our project templates, see: http://aka.ms/winui-project-info. |
@@ -169,29 +169,39 @@ public void Initialize() |
169 | 169 | // Mark as initialized |
170 | 170 | IsInitialized = true; |
171 | 171 |
|
172 | | - MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter()); |
173 | | - MemoryPackFormatterProvider.Register(new TrackedJointFormatter()); |
174 | | - |
175 | | - if (RelayService.Instance?.IsBackfeed ?? false) |
| 172 | + try |
176 | 173 | { |
177 | | - Status = RelayDeviceStatus.BackFeedDetected; |
178 | | - SettingsPage.DeviceStatusAppendix = string.Empty; |
179 | | - InitException = null; |
180 | | - return; // Don't proceed further |
181 | | - } |
| 174 | + MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter()); |
| 175 | + MemoryPackFormatterProvider.Register(new TrackedJointFormatter()); |
182 | 176 |
|
183 | | - var services = new ServiceCollection() |
184 | | - .AddLogging(); |
| 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 | + } |
185 | 184 |
|
186 | | - services.AddRpc() |
187 | | - .AddWebSocketClient($"http://{ServerIp}:{ServerPort}/") |
188 | | - .AddClient<IRelayService>(); |
| 185 | + var services = new ServiceCollection() |
| 186 | + .AddLogging(logging => logging.AddConsole()); |
189 | 187 |
|
190 | | - ServiceChannel = services.BuildServiceProvider(); |
191 | | - Service = ServiceChannel.GetRequiredService<IRelayService>(); |
| 188 | + services.AddRpc() |
| 189 | + .AddWebSocketClient($"http://{ServerIp}:{ServerPort}/") |
| 190 | + .AddClient<IRelayService>() |
| 191 | + .AddServer<IRelayClient, DataClient>(); |
192 | 192 |
|
193 | | - SettingsPage.DeviceStatusAppendix = string.Empty; |
194 | | - SettingsPage.StartConnectionTest(); |
| 193 | + ServiceChannel = services.BuildServiceProvider(); |
| 194 | + Service = ServiceChannel.GetRequiredService<IRelayService>(); |
| 195 | + |
| 196 | + SettingsPage.DeviceStatusAppendix = string.Empty; |
| 197 | + SettingsPage.StartConnectionTest(); |
| 198 | + } |
| 199 | + catch (Exception ex) |
| 200 | + { |
| 201 | + InitException = ex; |
| 202 | + Status = RelayDeviceStatus.ServiceError; |
| 203 | + return; |
| 204 | + } |
195 | 205 |
|
196 | 206 | Host.Log($"Tried to initialize with status: {DeviceStatusString}"); |
197 | 207 | InitException = null; |
|
0 commit comments