Beispiel #1
0
        public async Task ConnectToRoom(int roomId, string playerId)
        {
            _logger.LogInformation($"Player {playerId} is trying to connect to room {roomId}");

            try
            {
                await _roomService.ConnectPlayerToRoomAsync(roomId, playerId);

                var room = await _roomsRepository.GetRoomByIdAsync(roomId);

                var user = await _userManager.FindByIdAsync(playerId);

                UserTransport player = new UserTransport(user);
                _logger.LogInformation($"Player {playerId} connected to room {roomId}");

                await Groups.AddToGroupAsync(Context.ConnectionId, roomId.ToString());

                await Clients.Group(roomId.ToString()).PlayerConnect(room.LeaderId, player);
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                await Clients.Caller.Error(ex.Message);
            }
        }
Beispiel #2
0
 public string ResetAccount(UserTransport user)
 {
     try
     {
         var password  = _ser.CreateRandomPassword();
         var nPassword = _ser.GetMd5Password(password);
         return("");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Beispiel #3
0
        public async Task <IActionResult> GetUserInfo(string id)
        {
            var user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                _logger.LogWarning("User does not exist");
                return(NotFound());
            }

            _logger.LogInformation($"Get information for user with id #{user.Id}");

            var res = new UserTransport(user);

            return(Ok(JsonConvert.SerializeObject(res,
                                                  new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            })));
        }