public async Task Connect(int topicId) { await Groups.AddToGroupAsync(Context.ConnectionId, topicId.ToString()); try { var userId = Context.User.Identity.IsAuthenticated ? Context.User.Identity.GetUserId() : null; await _topicService.AddView(userId, topicId); } catch { await Groups.RemoveFromGroupAsync(Context.ConnectionId, topicId.ToString()); } }