public override async Task OnActivateAsync()
        {
            await base.OnActivateAsync();

            _hubContext = GrainFactory.GetHub <IUserNotificationHub>();

            var item = new UserNotification
            {
                MessageCount = 0
            };

            await Set(item);

            RegisterTimer(async x =>
            {
                State.UserNotification.MessageCount = RandomUtils.GenerateNumber(1, 100);
                await Set(State.UserNotification);

                var userNotification = new UserNotification
                {
                    MessageCount = item.MessageCount
                };

                await _hubContext.User(PrimaryKey).SendSignalRMessage("Broadcast", userNotification);
            }, State, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3));
        }
예제 #2
0
        public override async Task OnActivateAsync()
        {
            _hubContext = GrainFactory.GetHub <IUserNotificationHub>();

            _logger.LogInformation("{Source} :: OnActivateAsync PK {PK}", Source, this.GetPrimaryKeyString());
            var item = new UserNotification
            {
                MessageCount = 0
            };

            await Set(item);

            RegisterTimer(async x =>
            {
                State.UserNotification.MessageCount = _random.Next(100);
                await Set(State.UserNotification);

                var userNotification = new UserNotification
                {
                    MessageCount = item.MessageCount
                };

                await _hubContext.User(this.GetPrimaryKeyString()).SendSignalRMessage("Broadcast", userNotification);
            }, State, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3));
        }