Add SignalR integration for real-time weather updates

Implemented SignalR to enable real-time communication between the server and connected clients. Added a new hub (`WeatherUpdateHub`), a background service (`SignalRSendService`), and modified both the API backend and React frontend for seamless message broadcasting and handling.
This commit is contained in:
2025-02-06 22:21:53 +01:00
parent 892b2183e0
commit be2599218d
12 changed files with 202 additions and 15 deletions

View File

@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.SignalR;
namespace Api.SignalR
{
public class WeatherUpdateHub: Hub
{
// This method can be called by connected clients.
public async Task SendMessage(string user, string message)
{
// Broadcast the message to all connected clients.
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}