Inheritance: BaseSocketViewModel
コード例 #1
0
 public void PublishCommentAdded(CommentAdded commentAdded)
 {
     using (var svc = new ServiceProxyHelper<INotificationService>("NotificationService"))
     {
         svc.Proxy.PublishCommentAdded(commentAdded);
     }
 }
コード例 #2
0
        public ActionResult SendMessage(NotificationModel model)
        {
            if (!ModelState.IsValid)
            {
                return Json(ModelState, JsonRequestBehavior.AllowGet);
            }

            switch (model.Type)
            {
                case "CommentAdded":
                    {
                        var data = new CommentAdded
                                   {
                                       ClientFunction = Constants.SocketClientFunctions.CommentAdded.ToString(),
                                       PostId = model.ChannelId ?? 1,
                                       Comment = new Comment { Id = 99, PostId = model.ChannelId ?? 1, CommentMessage = "Foo bar" }
                                   };
                        _notificationResource.PublishCommentAdded(data);
                    }
                    break;
                case "CommentLikesUpdate":
                    {
                        var data = new CommentLikesUpdate
                        {
                            ClientFunction = Constants.SocketClientFunctions.CommentLikesUpdate.ToString(),
                            CommentId = 1,
                            PostId = model.ChannelId ?? 1,
                            CommentLikes = new List<CommentLike>
                                           {
                                               new CommentLike { CommentId = 1, UserId = 1},
                                               new CommentLike { CommentId = 1, UserId = 2},
                                           }
                        };
                        _notificationResource.PublishCommentLikesUpdate(data);
                    }
                    break;
                case "PostLikesUpdate":
                    {
                        var data = new PostLikesUpdate
                        {
                            ClientFunction = Constants.SocketClientFunctions.PostLikesUpdate.ToString(),
                            PostId = model.ChannelId ?? 1,
                            PostLikes = new List<PostLike>
                                           {
                                               new PostLike { PostId = model.ChannelId ?? 1, UserId = 1},
                                               new PostLike { PostId = model.ChannelId ?? 1, UserId = 2},
                                           }
                        };
                        _notificationResource.PublishPostLikesUpdate(data);
                    }
                    break;
                default:
                    _notificationResource.PublishMessage(model.Message);
                    break;
            }

            return Json(new { Message = "Success" }, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
ファイル: CommentsHub.cs プロジェクト: jsnmgpnty/Blogness2.0
 public void CommentAddedForPost(CommentAdded commentAdded)
 {
     try
     {
         _httpClientHelper.Post(_configurationHelper.GetAppSettings("BlogRoot"), "hub/commentAddedForPost?format=json", commentAdded);
     }
     catch (Exception ex)
     {
         _errorSignaler.SignalFromCurrentContext(ex);
     }
 }
コード例 #4
0
        public Comment Add(Comment comment)
        {
            var postId = comment.PostId;
            if (comment.ParentCommentId != null)
            {
                comment.PostId = null;
            }

            var result = _commentsLogic.Add(comment);
            if (result != null && result.Error != null) throw new Exception(result.Error.Message);

            var commentAdded = new CommentAdded
            {
                CommentId = comment.ParentCommentId,
                PostId = postId,
                Comment = result,
                ClientFunction = Constants.SocketClientFunctions.CommentAdded.ToString()
            };

            _redisService.Publish(commentAdded);
            return result;
        }
コード例 #5
0
 public void PublishCommentAdded(CommentAdded commentAdded)
 {
     _redisService.Publish(commentAdded);
 }
コード例 #6
0
 public void PublishCommentAdded(CommentAdded commentAdded)
 {
     throw new System.NotImplementedException();
 }