public void Send(int courseSid, string studentSid, string instructorSid, string name, string message) { // Call the addNewMessageToPage method to update clients. //Clients.All.addNewMessageToPage(Context.User.Identity.Name, message); if (message == null || string.IsNullOrEmpty(message)) { message = ""; } using (var chatManager = new ChatManager()) { try { string msg = string.Empty; Chat chat = new Chat() { CourseSid = courseSid, CreateDT = DateTime.Now, Message = message, StudentSid = string.IsNullOrEmpty(studentSid) ? null : int.Parse(studentSid) as int?, InstructorSid = string.IsNullOrEmpty(instructorSid) ? null : int.Parse(instructorSid) as int? }; if (string.IsNullOrEmpty(instructorSid)) { chatManager.AddStudentChatToCourse(chat, chat.StudentSid.Value, chat.CourseSid, out msg); } else if (string.IsNullOrEmpty(studentSid)) { chatManager.AddInstructorChatToCourse(chat, chat.InstructorSid.Value, chat.CourseSid, out msg); } } catch (Exception ex) { BaseManager.ExceptionLog(ex); } } Clients.Group(courseSid.ToString()).addNewMessageToPage(string.IsNullOrEmpty(studentSid) ? "Instructor" : "Student", studentSid, instructorSid, Context.User.Identity.Name, message); }