Skip to content

Commit 7e5c40d

Browse files
committed
public gateway and device id in interface
1 parent 33d4532 commit 7e5c40d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

SDK.CSharp.Live/IOpenShockLiveControlClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ namespace OpenShock.SDK.CSharp.Live;
55

66
public interface IOpenShockLiveControlClient
77
{
8+
public string Gateway { get; }
9+
public Guid DeviceId { get; }
10+
811
public IAsyncUpdatable<ulong> Latency { get; }
912
public IAsyncUpdatable<WebsocketConnectionState> State { get; }
1013

SDK.CSharp.Live/OpenShockLiveControlClient.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ public sealed class OpenShockLiveControlClient : IOpenShockLiveControlClient, IA
2323
Converters = { new CustomJsonStringEnumConverter() }
2424
};
2525

26-
private readonly string _gateway;
27-
private readonly Guid _deviceId;
26+
public string Gateway { get; }
27+
public Guid DeviceId { get; }
28+
2829
private readonly string _authToken;
2930
private readonly ILogger<OpenShockLiveControlClient> _logger;
3031
private ClientWebSocket? _clientWebSocket = null;
31-
32+
3233
public event Func<Task>? OnDeviceNotConnected;
3334
public event Func<Task>? OnDeviceConnected;
3435
public event Func<Task>? OnDispose;
@@ -43,8 +44,8 @@ private Channel<BaseRequest<LiveRequestType>>
4344
public OpenShockLiveControlClient(string gateway, Guid deviceId, string authToken,
4445
ILogger<OpenShockLiveControlClient> logger)
4546
{
46-
_gateway = gateway;
47-
_deviceId = deviceId;
47+
Gateway = gateway;
48+
DeviceId = deviceId;
4849
_authToken = authToken;
4950
_logger = logger;
5051

@@ -57,7 +58,9 @@ public OpenShockLiveControlClient(string gateway, Guid deviceId, string authToke
5758
private ValueTask QueueMessage(BaseRequest<LiveRequestType> data) =>
5859
_channel.Writer.WriteAsync(data, _dispose.Token);
5960

60-
private readonly AsyncUpdatableVariable<WebsocketConnectionState> _state = new(WebsocketConnectionState.Disconnected);
61+
private readonly AsyncUpdatableVariable<WebsocketConnectionState> _state =
62+
new(WebsocketConnectionState.Disconnected);
63+
6164
public IAsyncUpdatable<WebsocketConnectionState> State => _state;
6265

6366
private async Task MessageLoop()
@@ -108,7 +111,7 @@ private async Task<OneOf<Success, NotFound, Shutdown, Reconnecting>> ConnectAsyn
108111
_logger.LogInformation("Connecting to websocket....");
109112
try
110113
{
111-
await _clientWebSocket.ConnectAsync(new Uri($"wss://{_gateway}/1/ws/live/{_deviceId}"), _linked.Token);
114+
await _clientWebSocket.ConnectAsync(new Uri($"wss://{Gateway}/1/ws/live/{DeviceId}"), _linked.Token);
112115

113116
_logger.LogInformation("Connected to websocket");
114117
_state.Value = WebsocketConnectionState.Connected;
@@ -344,6 +347,7 @@ public Task Run(Task? function, CancellationToken cancellationToken = default, [
344347
}, TaskContinuationOptions.OnlyOnFaulted);
345348

346349
private readonly AsyncUpdatableVariable<ulong> _latency = new(0);
350+
347351
public IAsyncUpdatable<ulong> Latency => _latency;
348352

349353
public async Task SendFrame(ClientLiveFrame frame)

SDK.CSharp.Live/SDK.CSharp.Live.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<AssemblyName>OpenShock.SDK.CSharp.Live</AssemblyName>
99
<RootNamespace>OpenShock.SDK.CSharp.Live</RootNamespace>
1010
<Company>OpenShock</Company>
11-
<AssemblyVersion>0.0.19</AssemblyVersion>
12-
<Version>0.0.19</Version>
11+
<AssemblyVersion>0.0.20</AssemblyVersion>
12+
<Version>0.0.20</Version>
1313
<Title>SDK.DotNet.Live</Title>
1414
<Authors>OpenShock</Authors>
1515
<Description>Extension for OpenShock.SDK.CSharp</Description>

0 commit comments

Comments
 (0)