-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotificationHub.cs
33 lines (28 loc) · 923 Bytes
/
NotificationHub.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
// ReSharper disable once CheckNamespace
namespace SignalRChat.Hubs;
public class NotificationHub : Hub
{
private readonly ILogger<NotificationHub> _logger;
private string _currentValue;
public NotificationHub(ILogger<NotificationHub> logger)
{
_logger = logger;
_currentValue = "ctor";
_logger.LogInformation("NotificationHub ctor");
}
public async Task UpdateValue(string value)
{
_currentValue = value;
_logger.LogInformation("updated current value to {currentValue}", _currentValue);
await Clients.All.SendAsync("CurrentValue", _currentValue);
}
public async Task GetValue()
{
_logger.LogInformation("Get Value received");
await Clients.All.SendAsync("CurrentValue", _currentValue);
}
}