/// <summary> /// Hub method. Called when client broadcasts his/her read status on a specific message. /// Be advised. Only <see cref="MessageTypeEnum.Private"/> messages have status of read. /// </summary> /// <param name="messageId">The messageId generated by client side</param> /// <param name="username">The username of the client</param> /// <returns></returns> public async Task OnReadResponseReceived(string messageId, string username) { _logger.LogInformation(string.Format("OnReadResponseReceived messageId: {0}; username: {1}", messageId, username)); // Try to set read and store the message Message message = await _messageStorage.TryFetchMessageById(messageId); message.IsRead = true; bool success = await _messageStorage.TryUpdateMessageAsync(message); // Only send messages out when storage was a success if (success) { // Broadcast message read by user await Clients.Client(_userHandler.GetUserSession(message.Sender).ConnectionId) .SendAsync("clientRead", messageId, username); } }