コード例 #1
0
		public async Task<IActionResult> GetCharacterSessionDataByAccount([FromRoute(Name = "id")] int accountId)
		{
			if(!await CharacterSessionRepository.AccountHasActiveSession(accountId)
				.ConfigureAwaitFalse())
			{
				return Ok(new CharacterSessionDataResponse(CharacterSessionDataResponseCode.NoSessionAvailable));
			}

			//TODO: There is a dangerous race condition where the zoneserver can release a session inbetween the last databse call and the characte rsessin data call
			//This is unlikely to be exploitably but it is dangerous
			ProjectVersionStage.AssertBeta();

			try
			{
				ClaimedSessionsModel claimedSessionsModel = await CharacterSessionRepository.RetrieveClaimedSessionByAccountId(accountId)
					.ConfigureAwaitFalse();

				return Ok(new CharacterSessionDataResponse(claimedSessionsModel.Session.ZoneId, claimedSessionsModel.CharacterId));
			}
			catch(Exception e)
			{
				if(Logger.IsEnabled(LogLevel.Error))
					Logger.LogError($"Failed to query for character session data for active character session on AccountId: {accountId} Exception: {e.GetType().Name} - {e.Message}");

				return Ok(new CharacterSessionDataResponse(CharacterSessionDataResponseCode.GeneralServerError));
			}
		}
コード例 #2
0
        private static async Task <int> RetrieveSessionCharacterIdAsync(ICharacterSessionRepository characterSessionRepository, int accountId)
        {
            //TODO: Technically a race condition here.
            //Now let's actually get the character id of the session that the account has
            ClaimedSessionsModel session = await characterSessionRepository.RetrieveClaimedSessionByAccountId(accountId);

            int characterId = session.CharacterId;

            return(characterId);
        }