Oakrey.ASRockService.Client
2.0.5
dotnet add package Oakrey.ASRockService.Client --version 2.0.5
NuGet\Install-Package Oakrey.ASRockService.Client -Version 2.0.5
<PackageReference Include="Oakrey.ASRockService.Client" Version="2.0.5" />
<PackageVersion Include="Oakrey.ASRockService.Client" Version="2.0.5" />
<PackageReference Include="Oakrey.ASRockService.Client" />
paket add Oakrey.ASRockService.Client --version 2.0.5
#r "nuget: Oakrey.ASRockService.Client, 2.0.5"
#:package Oakrey.ASRockService.Client@2.0.5
#addin nuget:?package=Oakrey.ASRockService.Client&version=2.0.5
#tool nuget:?package=Oakrey.ASRockService.Client&version=2.0.5
Oakrey.ASRockService.Client
Project overview
Oakrey.ASRockService.Client is a .NET library that provides a strongly-typed client for the
ASRockService Windows service. It connects to the service over two channels: a SignalR hub
(MessagePack protocol) for write/control operations, and a plain HTTP REST API for state reads.
The primary entry point for consumers is the static AsRockFactory class.
Main features
| Type | Role |
|---|---|
AsRockFactory |
Static factory � the only public way to create a connected client instance |
IASRockClient |
Client contract: connect, read state (PSU, output, GPIO pins), write state, release |
ASRockClient |
Internal implementation; manages SignalR and HTTP connections |
HubClientConnection |
Builds the HubConnection with MessagePack protocol |
HubConnectionExtensions |
Extension method ConnectAsync with connection-ID validation |
Transport split
- Write operations (
SetPsu,SetOut,SetGpioOutState,SetGpioInput,ReleaseDevice) � SignalR hub invocation - Read operations (
GetPsuState,GetOutState,GetPinState,IsPinInput) � HTTP GET to the REST API
Architecture
graph TD
Consumer --> AsRockFactory
AsRockFactory --> ASRockClient
ASRockClient -->|SignalR MessagePack<br>port 4753 /devicehub| Service[ASRockService\nWindows Service]
ASRockClient -->|HTTP GET<br>port 4753 /api/devicelist| Service
Requirements
- .NET 10
- ASRockService Windows service running and reachable on
localhost:4753 - NuGet dependencies:
Microsoft.AspNetCore.SignalR.Client,Microsoft.AspNetCore.SignalR.Protocols.MessagePack,Oakrey.ASRockService.Common,Oakrey.Log
Installation
.NET CLI
dotnet add package Oakrey.ASRockService.Client
Package Manager Console
Install-Package Oakrey.ASRockService.Client
NuGet Package Manager
Search for Oakrey.ASRockService.Client in Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Example usage
Connect and control
using Oakrey.ASRockService.Client;
// Connect � throws InvalidOperationException if the service is not reachable
await using IASRockClient client = await AsRockFactory.GetDevice(CancellationToken.None);
// Read state via HTTP
bool psuOn = await client.GetPsuState(CancellationToken.None);
bool outOn = await client.GetOutState(CancellationToken.None);
bool pinOn = await client.GetPinState(71, CancellationToken.None);
bool isIn = await client.IsPinInput(71, CancellationToken.None);
// Write via SignalR
await client.SetPsu(true, CancellationToken.None);
await client.SetOut(false, CancellationToken.None);
await client.SetGpioOutState(72, true, CancellationToken.None);
await client.SetGpioInput(73, CancellationToken.None);
// Release the device (stops the SignalR connection)
await client.ReleaseDevice(CancellationToken.None);
Cancellation and timeout
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
await using IASRockClient client = await AsRockFactory.GetDevice(cts.Token);
await client.SetPsu(true, cts.Token);
Development notes
ASRockClienthas aninternalconstructor � instantiate only viaAsRockFactory.GetDevice.- The host is hardcoded to
localhostand the port to4753. There is no public constructor or options class to override these; changing them requires modifyingASRockClientdirectly. - The HTTP client uses a 2000 ms timeout. Ensure the service is fully started before calling
GetDevice. IASRockClientis decorated with[Guid, ComVisible(true)]and can be consumed from COM clients.DisposeonASRockClientcallsReleaseDevicesynchronously with a 2000 ms timeout; prefer callingReleaseDeviceexplicitly before disposal in async code.
License
MIT � Copyright (c) Oakrey 2016-present
- Author: Oakrey
- Repository: https://dev.azure.com/oakrey/OpenPackages/_git/Drivers
- Project URL: http://www.oakrey.cz/opkg_drivers_asrock
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.SignalR.Client (>= 10.0.9)
- Microsoft.AspNetCore.SignalR.Protocols.MessagePack (>= 10.0.9)
- Oakrey.ASRockService.Common (>= 2.0.2)
- Oakrey.Log.Abstractions (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.