/// <summary> /// Fired when a client pushes a message to the server. /// </summary> /// <param name="message"></param> public void Send(ChatMessage message) { if (!string.IsNullOrEmpty(message.Content)) { // Sanitize input message.Content = HttpUtility.HtmlEncode(message.Content); // Process URLs: Extract any URL and process rich content (e.g. Youtube links) HashSet<string> extractedURLs; message.Content = TextParser.TransformAndExtractUrls(message.Content, out extractedURLs); message.Timestamp = DateTime.Now; Clients.All.onMessageReceived(message); } }
/// <summary> /// Fired when a client pushes a message to the server. /// </summary> /// <param name="message"></param> public void Send(ChatMessage message) { if (!string.IsNullOrEmpty(message.Content)) { // Sanitize input message.Content = HttpUtility.HtmlEncode(message.Content); // Process URLs: Extract any URL and process rich content (e.g. Youtube links) HashSet<string> extractedUrLs; message.Content = TextParser.TransformAndExtractUrls(message.Content, out extractedUrLs); message.Timestamp = DateTime.Now; string userId = _repository.GetUserByConnectionId(Context.ConnectionId); var user = _repository.Users.FirstOrDefault(u => u.Id == userId); if (user != null) { var roomname = user.Roomname; Clients.Group(roomname).onMessageReceived(message); } } }