mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-02-16 10:58:32 -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",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"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": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"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<WeatherHub>("/weather");
|
||||||
endpoints.MapHub<PowerHub>("/power");
|
endpoints.MapHub<PowerHub>("/power");
|
||||||
|
endpoints.MapHub<DeviceStatusHub>("/device-status");
|
||||||
endpoints.MapDefaultControllerRoute();
|
endpoints.MapDefaultControllerRoute();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user