예제 #1
0
        public void SaveUserConnection(string userId, string connectionId)
        {
            var user = GetUserOrThrow(userId);

            if (user.LobbyParticipation == null)
            {
                throw new InvalidOperationException("User does not participate in any lobby");
            }
            user.LobbyParticipation.ConnectionIds.Add(connectionId);
            _dbContext.SaveChanges();
            var chatId = user.LobbyParticipation.LobbyID.ToString();

            _chatService.AddConnectionToChat(connectionId, chatId);
            if (user.LobbyParticipation.ConnectionIds.Count == 1)
            {
                _chatService.OnUserJoined(user.UserName, chatId);
            }
        }