public ServerEntryResponse(Guid sessionClaimGuid, ResolvedEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            SessionClaimGuid = sessionClaimGuid;
            Endpoint         = endpoint;
            ResultCode       = ServerEntryResponseCode.Success;
        }
Пример #2
0
        public GameServerInfo(string serverName, ClientRegionLocale serverLocale, ResolvedEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }
            if (string.IsNullOrWhiteSpace(serverName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(serverName));
            }
            if (!Enum.IsDefined(typeof(ClientRegionLocale), serverLocale))
            {
                throw new ArgumentOutOfRangeException(nameof(serverLocale), "Value should be defined in the ClientRegionLocale enum.");
            }

            ServerName   = serverName;
            ServerLocale = serverLocale;
            Endpoint     = endpoint;
        }
Пример #3
0
        public async Task <ResolveServiceEndpointResponseModel> Discover([FromBody] ResolveServiceEndpointRequestModel requestModel)
        {
            if (!ModelState.IsValid)
            {
                if (LoggingService.IsEnabled(LogLevel.Debug))
                {
                    LoggingService.LogDebug($"Resolution request was sent with an invalid model ModelState.");
                }

                return(new ResolveServiceEndpointResponseModel(ResolveServiceEndpointResponseCode.GeneralRequestError));
            }

            //We need to check if we know about the locale
            //If we don't we should indicate it is unlisted
            //We also need to check if the keypair region and servicetype exist
            if (!await EndpointRepository.HasEntryAsync(requestModel.Region, requestModel.ServiceType))
            {
                if (LoggingService.IsEnabled(LogLevel.Debug))
                {
                    LoggingService.LogDebug($"Client requested unlisted service Region: {requestModel.Region} Service: {requestModel.ServiceType}.");
                }

                return(new ResolveServiceEndpointResponseModel(ResolveServiceEndpointResponseCode.ServiceUnlisted));
            }

            ResolvedEndpoint endpoint = await EndpointRepository.RetrieveAsync(requestModel.Region, requestModel.ServiceType);

            if (endpoint == null)
            {
                //Log the error. It shouldn't be null if the checks passed
                if (LoggingService.IsEnabled(LogLevel.Error))
                {
                    LoggingService.LogError($"Resolution request {requestModel.ServiceType} for region {requestModel.Region} failed even through it was a known pair.");
                }

                return(new ResolveServiceEndpointResponseModel(ResolveServiceEndpointResponseCode.GeneralRequestError));
            }

            //Just return the JSON model response to the client
            return(new ResolveServiceEndpointResponseModel(endpoint));
        }