private void TimerElapsed(object sender, ElapsedEventArgs e) { lock (_updateNotificationsLock) { _counter++; var typeIndex = _randomGenerator.Next(Notification.AllTypes.Count()); var notification = new Notification(Guid.NewGuid()) { Title = "Some title " + _counter, Message = "Some message " + _counter, Type = Notification.AllTypes[typeIndex], UtcTimestamp = DateTime.UtcNow }; _onTick.Invoke(notification); if (_counter == uint.MaxValue) _counter = 0; } }
/// <summary> /// Do a conditional send to only clients listening for the actual notification type /// </summary> /// <param name="notification"></param> public void Notify(Notification notification) { // Send only to clients that is listening to this type this.SendTo(client => client.Listening && client.SelectedTypes.Contains(notification.Type), notification, "notify"); }