first commit -push
This commit is contained in:
28
RobotNet.WebApp/Clients/HMIHubClient.cs
Normal file
28
RobotNet.WebApp/Clients/HMIHubClient.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using RobotNet.Script.Shares;
|
||||
using RobotNet.Shares;
|
||||
|
||||
namespace RobotNet.WebApp.Clients;
|
||||
|
||||
public class HMIHubClient : WebAssemblyHubClient
|
||||
{
|
||||
public event Action<ProcessorState>? StateChanged;
|
||||
public event Action<ProcessorRequest>? RequestChanged;
|
||||
|
||||
public HMIHubClient(IAccessTokenProvider tokenProvider, Uri uri) : base(tokenProvider, uri)
|
||||
{
|
||||
Connection.On<ProcessorState>(nameof(StateChanged), OnStateChanged);
|
||||
Connection.On<ProcessorRequest>(nameof(RequestChanged), OnRequestChanged);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<ProcessorState> GetState() => await Connection.InvokeAsync<ProcessorState>(nameof(GetState));
|
||||
public async Task<ProcessorRequest> GetRequest() => await Connection.InvokeAsync<ProcessorRequest>(nameof(GetRequest));
|
||||
public async Task<IDictionary<string, string>> GetVariables(IEnumerable<string> keys) => await Connection.InvokeAsync<IDictionary<string, string>>(nameof(GetVariables), keys);
|
||||
public async Task<MessageResult> SetVariable(string key, string value) => await Connection.InvokeAsync<MessageResult>(nameof(SetVariable), key, value);
|
||||
|
||||
private void OnStateChanged(ProcessorState state) => StateChanged?.Invoke(state);
|
||||
private void OnRequestChanged(ProcessorRequest request) => RequestChanged?.Invoke(request);
|
||||
}
|
||||
Reference in New Issue
Block a user