2021-04-08 17:54:02 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.SignalR;
|
2021-04-09 17:59:07 +05:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-08 17:54:02 +05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2021-04-09 17:59:07 +05:00
|
|
|
|
namespace AsbCloudWebApi.SignalR
|
2021-04-08 17:54:02 +05:00
|
|
|
|
{
|
2021-04-09 17:59:07 +05:00
|
|
|
|
// SignalR manual:
|
|
|
|
|
// https://docs.microsoft.com/ru-ru/aspnet/core/signalr/introduction?view=aspnetcore-5.0
|
2021-04-08 17:54:02 +05:00
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
public class TelemetryHub : Hub<ITelemetryHubClient>
|
|
|
|
|
{
|
|
|
|
|
public Task AddToGroup(string groupName)
|
|
|
|
|
=> Groups.AddToGroupAsync(Context.ConnectionId, groupName.ToString());
|
|
|
|
|
|
|
|
|
|
public Task RemoveFromGroup(string groupName)
|
|
|
|
|
=> Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
|
|
|
|
|
2021-04-09 17:59:07 +05:00
|
|
|
|
public Task SendDataSaub(string groupName, IEnumerable<DataSaubBaseDto> data)
|
|
|
|
|
=> Clients.Group(groupName).ReceiveDataSaub(data);
|
2021-04-08 17:54:02 +05:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|