Пример #1
0
        public async Task SubscribeAsync(ClientRequestDetails clientRequestDetails)
        {
            if (!await _sessionProvider.CheckSessionForClientAsync(clientRequestDetails, default))
            {
                return;
            }

            await AddToGroupAsync(clientRequestDetails.SessionId);

            await _userRepo.SetConnectionIdAsync(clientRequestDetails.UserId, Context.ConnectionId, default);

            var user = await _userRepo.GetUserByIdAsync(clientRequestDetails.UserId, default);

            await Clients.GroupExcept(clientRequestDetails.SessionId, Context.ConnectionId).SendAsync("UserConnected", user);

            var users = await _userRepo.GetUsersBySessionIdAsync(clientRequestDetails.SessionId, default);

            await Clients.Caller.SendAsync("UserList", users);
        }