Introduced a `SendProgressUpdate` method in `WeatherUpdateHub` to allow sending progress messages specifically to the calling client. This enhances client feedback during operations.
20 lines
605 B
C#
20 lines
605 B
C#
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);
|
|
}
|
|
|
|
public async Task SendProgressUpdate(string message)
|
|
{
|
|
// Send a message to the caller.
|
|
await Clients.Caller.SendAsync("ProgressUpdate", message);
|
|
}
|
|
}
|
|
} |