Extended DeviceHub with update notifiers

This commit is contained in:
2020-11-11 20:35:26 +01:00
parent 4c1258dc33
commit f13133829a
4 changed files with 54 additions and 9 deletions

View File

@ -16,21 +16,31 @@ namespace Birdmap.API.Services.Hubs
public override Task OnConnectedAsync()
{
_logger.LogInformation("Client connected.");
_logger.LogInformation("Hub Client connected.");
return base.OnConnectedAsync();
}
public override Task OnDisconnectedAsync(Exception exception)
{
_logger.LogInformation("Client disconnected.");
_logger.LogInformation("Hub Client disconnected.");
return base.OnDisconnectedAsync(exception);
}
public Task SendNotification(Guid deviceId, DateTime date, double probability)
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();
}
}
}

View File

@ -6,5 +6,7 @@ namespace Birdmap.API.Services
public interface IDevicesHubClient
{
Task NotifyDeviceAsync(Guid deviceId, DateTime date, double probability);
Task NotifyDeviceUpdatedAsync(Guid deviceId);
Task NotifyAllUpdatedAsync();
}
}