/// <summary> /// Emite un mensaje a todos los clientes del HUB /// </summary> /// <param name="user">Nick del usuario que envía el mensaje</param> /// <param name="message">Texto del mensaje</param> /// <returns></returns> public async Task Send(string user, string message) { await UsersRegister.AddUser(user); var dateStr = $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"; await Clients.All.SendAsync("Send", user, message, dateStr); }
public async Task <IActionResult> Post([FromBody] MessagePost messageData) { await UsersRegister.AddUser(messageData.User); var dateStr = $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"; await MessagingHubContext.Clients.All.SendAsync("Send", messageData.User, messageData.Message, dateStr); return(Ok(messageData)); }