Пример #1
0
        public async void LoadContent(long commentId)
        {
            string resJosn = await WebProvider.GetInstance().GetRequestDataAsync($"http://news-at.zhihu.com/api/4/comment/{commentId}/replies");

            if (resJosn != string.Empty)
            {
                NotificationReply = JsonConvertHelper.JsonDeserialize <NotificationReply>(resJosn);
            }
        }
        public override async Task <NotificationReply> SendNotification(NotificationRequest request, ServerCallContext context)
        {
            _logger.LogInformation(
                $"Received notification for Group='{request.Topic.Group}';Id='{request.TrackingId}'");

            var notificationReply = new NotificationReply
            {
                TimeStamp   = DateTime.UtcNow.ToTimestamp(),
                ErrorResult = new ErrorResult()
            };

            try
            {
                await
                _pubSubHub.Clients
                .Group(request.Topic.Group)
                .NotificationSent(
                    new ClientNotificationEvent
                {
                    DateTime = DateTime.UtcNow,
                    Message  = request.Payload.Message
                });

                notificationReply.IsSuccess = true;
            }
            catch (Exception e)
            {
                notificationReply.ErrorResult.Errors.Add(
                    new ErrorResult.Types.Error
                {
                    Message = $"Failed to send message Id='{request.TrackingId}'",
                    Type    = e.GetType().ToString()
                });
            }

            return(notificationReply);
        }