public void CommentSave(string cmt, int msgid) { Comments comments = new Comments(); comments.Comment = cmt; comments.MessageId = msgid; HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; string UserName = authCookie["userName"].ToString(); UserModel matchUser = new UserModel(UserName); comments.DateCommented = DateTime.UtcNow; comments.UserId = matchUser.UserId; db.Comment.Add(comments); db.SaveChanges(); CommentContent comment = new CommentContent(); comment.UserName = UserName; comment.MessageId = comments.MessageId; comment.Comment = comments.Comment; comment.DateCommented = comments.DateCommented; var myhubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub1>(); myhubContext.Clients.All.NewComment(comment); }
public void NewComment(CommentContent comments) { Clients.All.NewComment("Hello message to all clients"); }