private OperationResponse HandleGetRegionListRequest(OperationRequest operationRequest, SendParameters sendParameters) { var regionListRequest = new Photon.NameServer.Operations.GetRegionListRequest(this.Protocol, operationRequest); //appid check since field is not required for standalone NS if (!regionListRequest.IsValid || !regionListRequest.ValidateApplicationId()) { this.HandleInvalidOperation(regionListRequest, sendParameters); return(null); } // authenticate application id ((PhotonCloudApp)this.application).AuthenticationCache.GetAccount(regionListRequest.ApplicationId, this.RequestFiber, account => this.OnGetApplicationAccountToGetRegionList(account, regionListRequest, sendParameters)); return(null); }
private void OnGetApplicationAccountToGetRegionList(ApplicationAccount appAccount, Photon.NameServer.Operations.GetRegionListRequest regionListRequest, SendParameters sendParameters) { if (!this.Connected) { return; } if (!appAccount.IsAuthenticated) { this.SendOperationResponse(new OperationResponse(regionListRequest.OperationRequest.OperationCode) { ReturnCode = (short)ErrorCode.InvalidAuthentication, DebugMessage = string.IsNullOrEmpty(appAccount.DebugMessage) ? ErrorMessages.InvalidAppId : appAccount.DebugMessage }, sendParameters); this.ScheduleDisconnect(this.GetDisconnectTime()); return; } if (log.IsDebugEnabled) { log.DebugFormat("GetRegionList for App ID {0}, Private Cloud {1}, Service Type {2}", regionListRequest.ApplicationId, appAccount.PrivateCloud, appAccount.ServiceType); } List <string> regions; List <string> endPoints; string message; if (!((PhotonCloudApp)this.application).CloudCache.GetRegionList(regionListRequest, appAccount, this.NetworkProtocol, this.LocalPort, this.LocalIPAddressIsIPv6, this.IsIPv6ToIPv4Bridged, out regions, out endPoints, out message)) { { this.SendOperationResponse(new OperationResponse((byte)OperationCode.GetRegionList) { ReturnCode = (short)ErrorCode.InvalidRegion, DebugMessage = message }, sendParameters); this.ScheduleDisconnect(this.GetDisconnectTime()); return; } } var regionListResponse = new Photon.NameServer.Operations.GetRegionListResponse { Endpoints = endPoints.ToArray(), Region = regions.ToArray() }; this.SendOperationResponse(new OperationResponse((byte)OperationCode.GetRegionList, regionListResponse), sendParameters); }