public static void SendMessageNewContact(Contact contact) { var msg = String.Format("Novo contato: {0} <{1}>", contact.Name, contact.Email); var hubContext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>(); hubContext.Clients.All.newContact(msg); }
// POST api/contacts public Contact Post(Contact contact) { contact.Id = Guid.NewGuid(); Contacts.Add(contact); NotificationHub.SendMessageNewContact(contact); return contact; }