Skip to content

Commit 561c8fd

Browse files
committed
preview 3
1 parent 19a77ef commit 561c8fd

5 files changed

Lines changed: 39 additions & 20 deletions

File tree

LocalRelay/DeviceConnection.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using System.Net;
22
using System.Net.WebSockets;
3-
using System.Reflection;
43
using System.Runtime.InteropServices;
54
using System.Text.Json;
65
using System.Threading.Channels;
76
using System.Timers;
7+
using LucHeart.WebsocketLibrary;
88
using Microsoft.Extensions.Logging;
99
using OneOf;
1010
using OneOf.Types;
1111
using OpenShock.LocalRelay.Models.Backend;
1212
using OpenShock.LocalRelay.Utils;
13-
using OpenShock.SDK.CSharp.Live.LiveControlModels;
1413
using OpenShock.SDK.CSharp.Updatables;
1514
using OpenShock.SDK.CSharp.Utils;
1615
using OpenShock.Serialization.Gateway;
@@ -221,7 +220,7 @@ private async Task Reconnect()
221220
{
222221
_logger.LogWarning("Reconnecting in 3 seconds");
223222

224-
_state.Value = WebsocketConnectionState.Reconnecting;
223+
_state.Value = WebsocketConnectionState.Connecting;
225224
_clientWebSocket?.Abort();
226225
_clientWebSocket?.Dispose();
227226
await Task.Delay(3000, _dispose.Token);
@@ -313,7 +312,7 @@ await _clientWebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Normal cl
313312
}
314313

315314
_logger.LogWarning("Lost websocket connection, trying to reconnect in 3 seconds");
316-
_state.Value = WebsocketConnectionState.Reconnecting;
315+
_state.Value = WebsocketConnectionState.Connecting;
317316

318317
_clientWebSocket?.Abort();
319318
_clientWebSocket?.Dispose();

LocalRelay/LocalRelay.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Company>OpenShock</Company>
1010
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1111
<ApplicationTitle>LocalRelay</ApplicationTitle>
12-
<Version>1.0.0-preview.2</Version>
12+
<Version>1.0.0-preview.3</Version>
1313
<Product>LocalRelay</Product>
1414
<TargetFramework>net9.0</TargetFramework>
1515

@@ -20,13 +20,13 @@
2020

2121
<ItemGroup>
2222
<PackageReference Include="CircularBuffer" Version="1.4.0" />
23-
<PackageReference Include="OpenShock.Desktop.ModuleBase" Version="1.0.0-preview.4" />
24-
<PackageReference Include="OpenShock.SDK.CSharp" Version="0.0.34" />
25-
<PackageReference Include="OpenShock.SDK.CSharp.Live" Version="0.0.33" />
23+
<PackageReference Include="OpenShock.Desktop.ModuleBase" Version="1.0.0-preview.5" />
24+
<PackageReference Include="OpenShock.SDK.CSharp" Version="0.0.38" />
25+
<PackageReference Include="OpenShock.SDK.CSharp.Live" Version="0.0.38" />
2626
<PackageReference Include="OpenShock.Serialization.Flatbuffers" Version="1.0.0" />
27-
<PackageReference Include="Serilog" Version="4.2.0" />
28-
<PackageReference Include="System.IO.Ports" Version="9.0.3" />
29-
<PackageReference Include="MudBlazor" Version="8.6.0" />
27+
<PackageReference Include="Serilog" Version="4.3.0" />
28+
<PackageReference Include="System.IO.Ports" Version="9.0.7" />
29+
<PackageReference Include="MudBlazor" Version="8.9.0" />
3030
<PackageReference Include="Semver" Version="3.0.0" />
3131
<PackageReference Include="System.Reactive" Version="6.0.1" />
3232
</ItemGroup>

LocalRelay/Services/FlowManager.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
using Microsoft.Extensions.Logging;
2-
using OneOf;
3-
using OneOf.Types;
1+
using LucHeart.WebsocketLibrary;
2+
using Microsoft.Extensions.Logging;
43
using OpenShock.Desktop.ModuleBase.Api;
54
using OpenShock.Desktop.ModuleBase.Config;
65
using OpenShock.LocalRelay.Config;
76
using OpenShock.LocalRelay.Models.Serial;
87
using OpenShock.MinimalEvents;
9-
using OpenShock.SDK.CSharp.Live.LiveControlModels;
108
using OpenShock.SDK.CSharp.Updatables;
11-
using OpenShock.SDK.CSharp.Utils;
129
using OpenShock.Serialization.Gateway;
1310

1411
namespace OpenShock.LocalRelay.Services;

LocalRelay/Ui/Pages/Dash/Tabs/HubTab.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@inject ILogger<SerialTab> Logger
2+
@using LucHeart.WebsocketLibrary
23
@using Microsoft.Extensions.Logging
34
@using OpenShock.Desktop.ModuleBase
45
@using OpenShock.Desktop.ModuleBase.Api
@@ -47,9 +48,8 @@
4748
state switch
4849
{
4950
WebsocketConnectionState.Connected => Color.Success,
50-
WebsocketConnectionState.Reconnecting => Color.Warning,
5151
WebsocketConnectionState.Connecting => Color.Warning,
52-
WebsocketConnectionState.Disconnected => Color.Error,
52+
WebsocketConnectionState.WaitingForReconnect => Color.Tertiary,
5353
_ => Color.Error
5454
};
5555

LocalRelay/Utils/FlatbufferWebSocketUtils.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Buffers;
22
using System.Net.WebSockets;
33
using FlatSharp;
4+
using Microsoft.IO;
45
using OneOf;
5-
using OpenShock.SDK.CSharp.Live.Utils;
66

77
namespace OpenShock.LocalRelay.Utils;
88

@@ -13,6 +13,8 @@ public static class FlatbufferWebSocketUtils
1313
{
1414
private const uint MaxMessageSize = 512_000; // 512 000 bytes
1515

16+
public static readonly RecyclableMemoryStreamManager RecyclableMemory = new();
17+
1618
/// <summary>
1719
/// Receive a websocket message with the given FlatBuffer type
1820
/// </summary>
@@ -30,7 +32,7 @@ public static class FlatbufferWebSocketUtils
3032
try
3133
{
3234
ValueWebSocketReceiveResult result;
33-
await using var message = JsonWebSocketUtils.RecyclableMemory.GetStream();
35+
await using var message = RecyclableMemory.GetStream();
3436
var bytes = 0;
3537
do
3638
{
@@ -106,4 +108,25 @@ private static async Task SendFullMessageBytes(ReadOnlyMemory<byte> msg, WebSock
106108
await socket.SendAsync(buffer, WebSocketMessageType.Binary, doneBytes >= msg.Length, cancelToken);
107109
}
108110
}
111+
}
112+
113+
public readonly struct WebsocketClosure;
114+
115+
public readonly struct DeserializeFailed
116+
{
117+
public Exception Exception { get; init; }
118+
public string Message { get; init; }
119+
}
120+
121+
public class MessageTooLongException : Exception
122+
{
123+
/// <inheritdoc />
124+
public MessageTooLongException()
125+
{
126+
}
127+
128+
/// <inheritdoc />
129+
public MessageTooLongException(string message) : base(message)
130+
{
131+
}
109132
}

0 commit comments

Comments
 (0)