public IActionResult Index() { var clickCount = _storage.GetClickCount(); var model = new HomeModel { ClickCount = clickCount }; return(View(model)); }
public void HandleEvent(ClickedEvent @event) { int oldClickCount = _storage.GetClickCount(); int newClickCount = oldClickCount + 1; _logger.LogInformation("Noticed a click! Click count is now {ClickCount}", newClickCount); _storage.StoreClickCount(newClickCount); Task.Run(() => _hubContext.Clients.All.SendAsync("Click", newClickCount)).GetAwaiter().GetResult(); _logger.LogDebug("Stored and broadcast click count {ClickCount} to SignalR clients", newClickCount); }