コード例 #1
0
        public async void getNotification(int userId, string stringGuid)
        {
            ConcurrentDictionary <int, List <NotificationDto> > notificationDict = await GetorCreateAsync();

            string notificationStr = JsonConvert.SerializeObject(notificationDict.FirstOrDefault(x => x.Key == userId).Value);
            await _sseService.SendEventsAsync(notificationStr, true, stringGuid);
        }
コード例 #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                await _sseService.SendEventsAsync(String.Format(HEARTBEAT_MESSAGE_FORMAT, DateTime.UtcNow), false);

                await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
            }
        }