public async Task <IActionResult> TryClaimSession([FromBody] ZoneServerTryClaimSessionRequest request)
        {
            //TODO: Renable auth for session claiming
            ProjectVersionStage.AssertAlpha();

            if (!this.ModelState.IsValid)
            {
                return(BadRequest());                //TODO: Send JSON back too.
            }
            //TODO: We should validate a lot things. One, that the character has a session on this zoneserver.
            //We should also validate that the account owns the character. We need a new auth process for entering users.
            //We have to do this validation, somehow. Or malicious players could spoof this.
            ProjectVersionStage.AssertAlpha();

            //TODO: Verify that the zone id is correct. Right now we aren't providing it and the query doesn't enforce it.
            //We don't validate characterid/accountid association manually. It is implemented in the tryclaim SQL instead.
            //It additionally also checks the zone relation for the session so it will fail if it's invalid for the provided zone.
            //Therefore we don't need to make 3/4 database calls/queries to claim a session. Just one stored procedure call.
            //This is preferable. A result code will be used to indicate the exact error in the future. For now it just fails if it fails.
            bool sessionClaimed = await CharacterSessionRepository.TryClaimUnclaimedSession(request.PlayerAccountId, request.CharacterId);

            return(Ok(new ZoneServerTryClaimSessionResponse(sessionClaimed ? ZoneServerTryClaimSessionResponseCode.Success : ZoneServerTryClaimSessionResponseCode.GeneralServerError)));            //TODO
        }
Exemple #2
0
 /// <inheritdoc />
 public async Task <ZoneServerTryClaimSessionResponse> TryClaimSession(ZoneServerTryClaimSessionRequest request)
 {
     return(await(await GetService().ConfigureAwait(false)).TryClaimSession(request).ConfigureAwait(false));
 }