Add device status to hub service

This commit is contained in:
2022-08-17 15:58:43 -04:00
parent 30be1ee202
commit 054396d242
3 changed files with 21 additions and 1 deletions

View File

@@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/ChrisKaczor.HomeMonitor.Hub.Service.dll",
"program": "${workspaceFolder}/bin/Debug/net5.0/ChrisKaczor.HomeMonitor.Hub.Service.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,

View File

@@ -0,0 +1,19 @@
using JetBrains.Annotations;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Threading.Tasks;
namespace ChrisKaczor.HomeMonitor.Hub.Service.Hubs
{
[UsedImplicitly]
public class DeviceStatusHub : Microsoft.AspNetCore.SignalR.Hub
{
[UsedImplicitly]
public async Task SendLatestStatus(string message)
{
Console.WriteLine(message);
await Clients.Others.SendAsync("LatestStatus", message);
}
}
}

View File

@@ -33,6 +33,7 @@ namespace ChrisKaczor.HomeMonitor.Hub.Service
{
endpoints.MapHub<WeatherHub>("/weather");
endpoints.MapHub<PowerHub>("/power");
endpoints.MapHub<DeviceStatusHub>("/device-status");
endpoints.MapDefaultControllerRoute();
});
}