mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Add device status to hub service
This commit is contained in:
2
Hub/Service/.vscode/launch.json
vendored
2
Hub/Service/.vscode/launch.json
vendored
@@ -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,
|
||||
|
||||
19
Hub/Service/Hubs/DeviceStatusHub.cs
Normal file
19
Hub/Service/Hubs/DeviceStatusHub.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ namespace ChrisKaczor.HomeMonitor.Hub.Service
|
||||
{
|
||||
endpoints.MapHub<WeatherHub>("/weather");
|
||||
endpoints.MapHub<PowerHub>("/power");
|
||||
endpoints.MapHub<DeviceStatusHub>("/device-status");
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user