Added dashboard services
Added GetCount endpoint Added ServiceInfo Skeletons
This commit is contained in:
@ -16,31 +16,16 @@ namespace Birdmap.API.Services.Hubs
|
||||
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
_logger.LogInformation("Hub Client connected.");
|
||||
_logger.LogInformation("Devices Hub Client connected.");
|
||||
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
public override Task OnDisconnectedAsync(Exception exception)
|
||||
{
|
||||
_logger.LogInformation("Hub Client disconnected.");
|
||||
_logger.LogInformation("Devices Hub Client disconnected.");
|
||||
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
|
||||
public Task SendProbabilityAsync(Guid deviceId, DateTime date, double probability)
|
||||
{
|
||||
return Clients.All.NotifyDeviceAsync(deviceId, date, probability);
|
||||
}
|
||||
|
||||
public Task SendDeviceUpdateAsync(Guid deviceId)
|
||||
{
|
||||
return Clients.All.NotifyDeviceUpdatedAsync(deviceId);
|
||||
}
|
||||
|
||||
public Task SendAllUpdatedAsync()
|
||||
{
|
||||
return Clients.All.NotifyAllUpdatedAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
Birdmap.API/Services/Hubs/IServicesHubClient.cs
Normal file
9
Birdmap.API/Services/Hubs/IServicesHubClient.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Birdmap.API.Services.Hubs
|
||||
{
|
||||
public interface IServicesHubClient
|
||||
{
|
||||
Task NotifyUpdatedAsync();
|
||||
}
|
||||
}
|
31
Birdmap.API/Services/Hubs/ServicesHub.cs
Normal file
31
Birdmap.API/Services/Hubs/ServicesHub.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Birdmap.API.Services.Hubs
|
||||
{
|
||||
public class ServicesHub : Hub<IServicesHubClient>
|
||||
{
|
||||
private readonly ILogger<ServicesHub> _logger;
|
||||
|
||||
public ServicesHub(ILogger<ServicesHub> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
_logger.LogInformation("Services Hub Client connected.");
|
||||
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
public override Task OnDisconnectedAsync(Exception exception)
|
||||
{
|
||||
_logger.LogInformation("Services Hub Client disconnected.");
|
||||
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,6 @@ namespace Birdmap.API.Services
|
||||
IMqttClientDisconnectedHandler,
|
||||
IMqttApplicationMessageReceivedHandler
|
||||
{
|
||||
|
||||
public bool IsConnected { get; }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ using MQTTnet.Client.Disconnecting;
|
||||
using MQTTnet.Client.Options;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -24,6 +23,8 @@ namespace Birdmap.API.Services.Mqtt
|
||||
private readonly IInputService _inputService;
|
||||
private readonly IHubContext<DevicesHub, IDevicesHubClient> _hubContext;
|
||||
|
||||
public bool IsConnected => _mqttClient.IsConnected;
|
||||
|
||||
public MqttClientService(IMqttClientOptions options, ILogger<MqttClientService> logger, IInputService inputService, IHubContext<DevicesHub, IDevicesHubClient> hubContext)
|
||||
{
|
||||
_options = options;
|
||||
|
Reference in New Issue
Block a user