public IEnumerator LoadListFromWeb(string listDownloadPath) { var downloaded = false; var downloader = new HTTPConnection(); AssetBundleList listObj = null; yield return(downloader.Get( "loadListFromWeb", null, listDownloadPath, (conId, code, respHeaders, data) => { downloaded = true; listObj = JsonUtility.FromJson <AssetBundleList>(data); }, (conId, code, reason, respHeaders) => { Debug.LogError("failed conId:" + conId + " code:" + code + " reason:" + reason); } )); yield return(WaitUntil( () => downloaded, () => { throw new TimeoutException("failed to download list."); } )); yield return(listObj); }
internal ConnectionBase GetNextAvailable(HTTPRequest request) { int activeConnections = 0; ConnectionBase conn = null; // Check the last created connection first. This way, if a higher level protocol is present that can handle more requests (== HTTP/2) that protocol will be chosen // and others will be closed when their inactivity time is reached. for (int i = Connections.Count - 1; i >= 0; --i) { conn = Connections[i]; if (conn.State == HTTPConnectionStates.Initial || conn.State == HTTPConnectionStates.Free || conn.CanProcessMultiple) { HTTPManager.Logger.Verbose("HostConnection", string.Format("GetNextAvailable - returning with connection. state: {0}, CanProcessMultiple: {1}", conn.State, conn.CanProcessMultiple), this.Context, request.Context, conn.Context); return(conn); } activeConnections++; } if (activeConnections >= HTTPManager.MaxConnectionPerServer) { HTTPManager.Logger.Verbose("HostConnection", string.Format("GetNextAvailable - activeConnections({0}) >= HTTPManager.MaxConnectionPerServer({1})", activeConnections, HTTPManager.MaxConnectionPerServer), this.Context, request.Context); return(null); } string key = HostDefinition.GetKeyForRequest(request); conn = null; #if UNITY_WEBGL && !UNITY_EDITOR conn = new WebGLConnection(key); #else if (request.CurrentUri.IsFile) { conn = new FileConnection(key); } else { #if !BESTHTTP_DISABLE_ALTERNATE_SSL // Hold back the creation of a new connection until we know more about the remote host's features. // If we send out multiple requests at once it will execute the first and delay the others. // While it will decrease performance initially, it will prevent the creation of TCP connections // that will be unused after their first request processing if the server supports HTTP/2. if (activeConnections >= 1 && (this.ProtocolSupport == HostProtocolSupport.Unknown || this.ProtocolSupport == HostProtocolSupport.HTTP2)) { HTTPManager.Logger.Verbose("HostConnection", string.Format("GetNextAvailable - waiting for protocol support message. activeConnections: {0}, ProtocolSupport: {1} ", activeConnections, this.ProtocolSupport), this.Context, request.Context); return(null); } #endif conn = new HTTPConnection(key); HTTPManager.Logger.Verbose("HostConnection", string.Format("GetNextAvailable - creating new connection, key: {0} ", key), this.Context, request.Context, conn.Context); } #endif Connections.Add(conn); return(conn); }
public HTTP2Handler(HTTPConnection conn) { this.conn = conn; this.isRunning = true; // Put the first request to the queue this.requestQueue.Enqueue(conn.CurrentRequest); }
/** * constructor. * * Func<string, Dictionary<string, string>> requestHeader func is used to get request header from outside of this feature. * by default it returns empty headers. * * also you can modify http error handling via httpResponseHandlingDelegate. * by default, http response code 200 ~ 299 is treated as success, and other codes are treated as network error. */ public PurchaseRouter( Action <IEnumerator> executor, Func <string, ProductInfo[]> onLoadProducts, Func <string, string> onTicketRequest, Func <string, string> onTicketResponse, Action onPurchaseReady, Action <PurchaseReadyError, int, string> onPurchaseReadyFailed, Action <string> onPurchaseCompletedInBackground = null, HttpRequestHeaderDelegate httpGetRequestHeaderDeletage = null, HttpResponseHandlingDelegate httpResponseHandlingDelegate = null ) { this.storeId = Guid.NewGuid().ToString(); this.enumExecutor = executor; /* * set store kind by platform. */ #if Update_PurchaseLib this.storeKind = "dummy"; #elif UNITY_EDITOR this.storeKind = AppleAppStore.Name; #elif UNITY_IOS this.storeKind = AppleAppStore.Name; #elif UNITY_ANDROID this.storeKind = GooglePlay.Name; #endif if (httpGetRequestHeaderDeletage != null) { this.httpRequestHeaderDelegate = httpGetRequestHeaderDeletage; } else { this.httpRequestHeaderDelegate = BasicRequestHeaderDelegate; } this.http = new HTTPConnection(); if (httpResponseHandlingDelegate != null) { this.httpResponseHandlingDelegate = httpResponseHandlingDelegate; } else { this.httpResponseHandlingDelegate = BasicResponseHandlingDelegate; } this.onTicketRequest = onTicketRequest; this.onTicketResponse = onTicketResponse; this.onPurchaseCompletedInBackground = onPurchaseCompletedInBackground; var cor = _Ready(onLoadProducts, onPurchaseReady, onPurchaseReadyFailed); enumExecutor(cor); }
private Autoya(string basePath = "") { // Debug.LogWarning("autoya initialize start. basePath:" + basePath); var isPlayer = false; if (Application.isPlaying) { isPlayer = true; // create game object for Autoya. var go = GameObject.Find("AutoyaMainthreadDispatcher"); if (go == null) { go = new GameObject("AutoyaMainthreadDispatcher"); this.mainthreadDispatcher = go.AddComponent <AutoyaMainThreadDispatcher>(); GameObject.DontDestroyOnLoad(go); } else { this.mainthreadDispatcher = go.GetComponent <AutoyaMainThreadDispatcher>(); } } else { // create editor runnner for Autoya. this.mainthreadDispatcher = new EditorUpdator(); } _autoyaFilePersistence = new FilePersistence(basePath); _autoyaHttp = new HTTPConnection(); InitializeAssetBundleFeature(); InitializeAppManifest(); var isFirstBoot = IsFirstBoot(); /* * start authentication. */ Authenticate( isFirstBoot, () => { /* * initialize purchase feature. */ if (isPlayer) { ReloadPurchasability(); } } ); }
public HTTP2Handler(HTTPConnection conn) { this.Context = new LoggingContext(this); this.conn = conn; this.isRunning = true; this.settings = new HTTP2SettingsManager(this); // Put the first request to the queue this.requestQueue.Enqueue(conn.CurrentRequest); }
public async override AsyncReply <bool> Execute(HTTPConnection sender) { if (sender.WSMode) { return(false); } string fn = RootPath + "/" + sender.Request.Filename.TrimStart('/'); // this is commented out for IUI router //if (Regex.IsMatch(sender.Request.Filename, @"^/?css|img|js|font|iui-js-2|node_modules|snd|view|wgt|iui|lib")) // fn = RootPath + "/" + sender.Request.Filename.TrimStart('/'); //else if (Regex.IsMatch(sender.Request.Filename, @"^/?" + UpPath)) //{ // fn = sender.Request.Filename.TrimStart('/'); //} //else //{ // fn = RootPath + "/index.html"; //} if (Path.GetExtension(fn) == null) { fn = RootPath + "/index.html"; } if (File.Exists(fn)) { var provider = new FileExtensionContentTypeProvider(); string contentType; if (!provider.TryGetContentType(fn, out contentType)) { contentType = "application/octet-stream"; } sender.Response.Headers["Content-Type"] = contentType; sender.SendFile(fn).Wait(20000); } else { sender.Response.Number = Esiur.Net.Packets.HTTPResponsePacket.ResponseCode.NotFound; sender.Send("`" + fn + "` Not Found"); } return(true); }
/** * constructor. * * Func<string, Dictionary<string, string>> requestHeader func is used to get request header from outside of this feature. * by default it returns empty headers. * * also you can modify http error handling via httpResponseHandlingDelegate. * by default, http response code 200 ~ 299 is treated as success, and other codes are treated as network error. */ public PurchaseRouter( Action <IEnumerator> executor, Func <string, ProductInfo[]> onLoadProducts, Func <string, string> onTicketResponse, Action onPurchaseReady, Action <PurchaseError, string, AutoyaStatus> onPurchaseReadyFailed, Autoya.HttpRequestHeaderDelegate httpGetRequestHeaderDeletage = null, Autoya.HttpResponseHandlingDelegate httpResponseHandlingDelegate = null ) { this.storeId = Guid.NewGuid().ToString(); // Debug.LogError("start storeId:" + storeId); this.enumExecutor = executor; /* * set store kind by platform. */ #if UNITY_EDITOR this.storeKind = AppleAppStore.Name; #elif UNITY_IOS this.storeKind = AppleAppStore.Name; #elif UNITY_ANDROID this.storeKind = GooglePlay.Name; #endif if (httpGetRequestHeaderDeletage != null) { this.requestHeader = httpGetRequestHeaderDeletage; } else { this.requestHeader = BasicRequestHeaderDelegate; } this.http = new HTTPConnection(); if (httpResponseHandlingDelegate != null) { this.httpResponseHandlingDelegate = httpResponseHandlingDelegate; } else { this.httpResponseHandlingDelegate = BasicResponseHandlingDelegate; } this.onTicketResponse = onTicketResponse; var cor = _Ready(onLoadProducts, onPurchaseReady, onPurchaseReadyFailed); enumExecutor(cor); }
public static async Task <WebAPIResult> ExecuteWebAPIRequest(HttpMethod httpMethod, string URL, string headerKeyName, string headerKeyValue, string contentBody = "", bool generateException = true) { var result = new WebAPIResult(); // Create the Http Request Message using (var request = new HttpRequestMessage(httpMethod, URL)) { // Add the access token and specify that the return value is required in JSON format request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // For API Key based auth request.Headers.Add(headerKeyName, headerKeyValue); //If the contentBody != "", attach it if (contentBody != "") { request.Content = new StringContent(contentBody, Encoding.UTF8, "application/json"); request.Content.Headers.ContentLength = contentBody.Length; } using (var response = await HTTPConnection.SendAsync(request)) { result.ReponseCode = response.StatusCode; result.ReponseContent = await response.Content.ReadAsStringAsync(); } //Check to see if there are exceptions thrown from the Web API, thrown an exception //if (result.ReponseCode == HttpStatusCode.OK) return result; if (generateException && result.ReponseCode != HttpStatusCode.OK) { // Get the error details from the SAP message JObject errorInfo = JObject.Parse(result.ReponseContent); string errorCode = (string)errorInfo["error"]["statusCode"]; string errorMessage = (string)errorInfo["error"]["message"]; var error = new WebAPIException(errorCode, errorMessage); throw error; } else { return(result); } } }
public override AsyncReply <bool> Execute(HTTPConnection sender) { if (sender.Request.URL != "iip") { return(new AsyncReply <bool>(false)); } IIPPacket.IIPPacketAction action = (IIPPacket.IIPPacketAction)Convert.ToByte(sender.Request.Query["a"]); if (action == IIPPacket.IIPPacketAction.QueryLink) { EntryPoint.Query(sender.Request.Query["l"], null).Then(x => { }); } return(new AsyncReply <bool>(true)); }
// Use this for initialization void Start() { var http = new HTTPConnection(); var con = http.Get( "info", new Dictionary <string, string>(), "https://raw.githubusercontent.com/sassembla/Autoya/master/README.md", (conId, code, respHeader, data) => { Debug.Log("markdown:" + data); Autoya.Info_ConstructMarkdownView(data, windowObj => {}, id => {}); }, (conId, code, reason, respHeader) => { Debug.LogError("failed to dl, reason:" + reason); } ); StartCoroutine(con); }
private IEnumerator TokenRefreshRetryCoroutine() { // wait 2, 4, 8... sec. var refreshTokenRetryWait = Math.Pow(2, tokenRefreshRetryCount); if (forceFailTokenRefresh) { // set 0sec for shortcut. refreshTokenRetryWait = 0; } var limitTick = DateTime.Now.Ticks + TimeSpan.FromSeconds(refreshTokenRetryWait).Ticks; while (DateTime.Now.Ticks < limitTick) { yield return(null); } // start refreshing token again. var refresingTokenHttp = new HTTPConnection(); var refreshTokenUrl = AuthSettings.AUTH_URL_REFRESH_TOKEN; var refreshTokenConnectionId = AuthSettings.AUTH_CONNECTIONID_REFRESH_TOKEN_PREFIX + Guid.NewGuid().ToString(); Dictionary <string, string> refreshRequestHeader = null; var refreshTokenData = string.Empty; Action <Dictionary <string, string>, string> refreshRequestHeaderLoaded = (requestHeader, data) => { refreshRequestHeader = requestHeader; refreshTokenData = data; }; var authKeyLoadCor = autoya.OnTokenRefreshRequest(refreshRequestHeaderLoaded); while (authKeyLoadCor.MoveNext()) { yield return(null); } if (string.IsNullOrEmpty(refreshTokenData)) { var cor = refresingTokenHttp.Get( refreshTokenConnectionId, refreshRequestHeader, refreshTokenUrl, (conId, code, responseHeader, data) => { OnRefreshResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnRefreshResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } else { var cor = refresingTokenHttp.Post( refreshTokenConnectionId, refreshRequestHeader, refreshTokenUrl, refreshTokenData, (conId, code, responseHeader, data) => { OnRefreshResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnRefreshResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } }
private IEnumerator RefreshToken() { // start refreshing token. var refresingTokenHttp = new HTTPConnection(); var refreshTokenUrl = AuthSettings.AUTH_URL_REFRESH_TOKEN; var refreshTokenConnectionId = AuthSettings.AUTH_CONNECTIONID_REFRESH_TOKEN_PREFIX + Guid.NewGuid().ToString(); Dictionary <string, string> refreshRequestHeader = null; var refreshTokenData = string.Empty; Action <Dictionary <string, string>, string> refreshRequestHeaderLoaded = (requestHeader, data) => { refreshRequestHeader = requestHeader; refreshTokenData = data; }; var authKeyLoadCor = autoya.OnTokenRefreshRequest(refreshRequestHeaderLoaded); while (authKeyLoadCor.MoveNext()) { yield return(null); } if (string.IsNullOrEmpty(refreshTokenData)) { var refreshingTokenCor = refresingTokenHttp.Get( refreshTokenConnectionId, refreshRequestHeader, refreshTokenUrl, (conId, code, responseHeader, data) => { OnRefreshResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnRefreshResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (refreshingTokenCor.MoveNext()) { yield return(null); } } else { var refreshingTokenCor = refresingTokenHttp.Post( refreshTokenConnectionId, refreshRequestHeader, refreshTokenUrl, refreshTokenData, (conId, code, responseHeader, data) => { OnRefreshResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnRefreshResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (refreshingTokenCor.MoveNext()) { yield return(null); } } }
private IEnumerator BootRetryCoroutine() { // wait 2, 4, 8... sec. var bootRetryWait = Math.Pow(2, bootRetryCount); if (forceFailFirstBoot) { // set 0sec for shortcut. bootRetryWait = 0; } var limitTick = DateTime.Now.Ticks + TimeSpan.FromSeconds(bootRetryWait).Ticks; while (DateTime.Now.Ticks < limitTick) { yield return(null); } // start boot authentication again. var tokenHttp = new HTTPConnection(); var tokenConnectionId = AuthSettings.AUTH_CONNECTIONID_BOOT_PREFIX + Guid.NewGuid().ToString(); var tokenUrl = AuthSettings.AUTH_URL_BOOT; Dictionary <string, string> tokenRequestHeader = null; var bootData = string.Empty; Action <Dictionary <string, string>, string> authRequestHeaderLoaded = (requestHeader, data) => { tokenRequestHeader = requestHeader; bootData = data; }; var bootKeyLoadCor = autoya.OnBootAuthRequest(authRequestHeaderLoaded); while (bootKeyLoadCor.MoveNext()) { yield return(null); } if (string.IsNullOrEmpty(bootData)) { var cor = tokenHttp.Get( tokenConnectionId, tokenRequestHeader, tokenUrl, (conId, code, responseHeader, data) => { OnBootResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnBootResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } else { var cor = tokenHttp.Post( tokenConnectionId, tokenRequestHeader, tokenUrl, bootData, (conId, code, responseHeader, data) => { OnBootResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnBootResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } }
private IEnumerator FirstBoot() { var tokenHttp = new HTTPConnection(); var tokenConnectionId = AuthSettings.AUTH_CONNECTIONID_BOOT_PREFIX + Guid.NewGuid().ToString(); var tokenUrl = AuthSettings.AUTH_URL_BOOT; Dictionary <string, string> tokenRequestHeader = null; var bootData = string.Empty; Action <Dictionary <string, string>, string> authRequestHeaderLoaded = (requestHeader, data) => { tokenRequestHeader = requestHeader; bootData = data; }; var bootKeyLoadCor = autoya.OnBootAuthRequest(authRequestHeaderLoaded); while (bootKeyLoadCor.MoveNext()) { yield return(null); } if (string.IsNullOrEmpty(bootData)) { var cor = tokenHttp.Get( tokenConnectionId, tokenRequestHeader, tokenUrl, (conId, code, responseHeader, data) => { OnBootResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnBootResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } else { var cor = tokenHttp.Post( tokenConnectionId, tokenRequestHeader, tokenUrl, bootData, (conId, code, responseHeader, data) => { OnBootResult(conId, responseHeader, code, data, string.Empty); }, (conId, code, failedReason, responseHeader) => { OnBootResult(conId, responseHeader, code, string.Empty, failedReason); }, BackyardSettings.HTTP_TIMEOUT_SEC ); while (cor.MoveNext()) { yield return(null); } } }
public override AsyncReply <bool> Execute(HTTPConnection sender) { if (sender.IsWebsocketRequest()) { if (Server == null) { return(new AsyncReply <bool>(false)); } var tcpSocket = sender.Unassign(); if (tcpSocket == null) { return(new AsyncReply <bool>(false)); } var httpServer = sender.Parent; var wsSocket = new WSocket(tcpSocket); httpServer.Remove(sender); var iipConnection = new DistributedConnection(); Server.Add(iipConnection); iipConnection.Assign(wsSocket); wsSocket.Begin(); return(new AsyncReply <bool>(true)); } return(new AsyncReply <bool>(false)); /* * if (sender.Request.Filename.StartsWith("/iip/")) * { * // find the service * var path = sender.Request.Filename.Substring(5);// sender.Request.Query["path"]; * * * Warehouse.Get(path).Then((r) => * { * if (r is DistributedServer) * { * var httpServer = sender.Parent; * var iipServer = r as DistributedServer; * var tcpSocket = sender.Unassign(); * if (tcpSocket == null) * return; * * var wsSocket = new WSSocket(tcpSocket); * httpServer.RemoveConnection(sender); * * //httpServer.Connections.Remove(sender); * var iipConnection = new DistributedConnection(); * // iipConnection.OnReady += IipConnection_OnReady; * // iipConnection.Server = iipServer; * // iipConnection.Assign(wsSocket); * * iipServer.AddConnection(iipConnection); * iipConnection.Assign(wsSocket); * wsSocket.Begin(); * } * }); * * return true; * } * * return false; */ }
public virtual void ClientDisconnected(HTTPConnection HTTP) { //return false; }
// Use this for initialization void Start() { if (_checkFinished == true) { //起動チェック済みだから気にしなくていいと思う return; } //端末固有番号を取得する。とは言えmacアドレス収集とかはセンシティブなので //本当はここを暗号化するとグッド! if (PlayerPrefs.HasKey("guid")) { myGuid = PlayerPrefs.GetString("guid"); } else { //izmのMacBookAir__q(長い文字列)we9werfgw___a(長い文字列)erwereqwrq3 みたいなのが取得出来て、こいつをGUIDとする myGuid = SystemInfo.deviceName + "__" + SystemInfo.deviceUniqueIdentifier + "__" + Guid.NewGuid().ToString(); PlayerPrefs.SetString("guid", myGuid); } _connectionID = Guid.NewGuid().ToString(); _connection = new HTTPConnection(); //Getのサンプル、最初に導通を確認したい的な StartCoroutine( _connection.Get(_connectionID, null, url, (s, i, arg3, responseBody) => { if (responseBody.Contains("available") == false) { Debug.LogAssertion("ウェブ側で起動制限を掛けてるよ~!!!"); //Maybe Quit Application?? //ここで、Getの文字列が規定じゃないってことはたぶん、開発者としてはアプリが流出してロックを掛けてるってことだから //アプリを終了させちゃっても良い気がする Application.Quit(); } Debug.Log(responseBody); }, (s, i, arg3, arg4) => { Debug.LogAssertion("http not connection"); //Maybe Quit Application?? //ここで、Getが通じないってことはたぶんオフラインか、リバースプロクシで妨害してるっぽいってことだから、 //アプリを終了させちゃっても良い気がする Application.Quit(); }, 10)); //ポストする DeviceInfo info = new DeviceInfo() { deviceName = SystemInfo.deviceName, guid = myGuid, appName = Application.productName, appVersion = Application.version, optionString = "default value" }; //ここでoptionに「初投稿です…ども…」とか入れる //Postして自分の端末情報をGoogle Spread Sheetに送る StartCoroutine(_connection.Post(_connectionID, null, url, JsonUtility.ToJson(info), (s, i, arg3, body) => { _checkFinished = true; Debug.Log("post success: " + body); }, (s, i, arg3, arg4) => { Debug.LogError("failed"); }, 5d)); }
public static async Task <WebAPIResult> ExecuteOAuthWebAPIRequest(HttpMethod httpMethod, string URL, string authBearerToken, string contentBody = "", bool generateException = true, string headerKeyName = null, string headerKeyValue = null) { //LoggerService.Debug("Sending request to API for URI: " + URL); var result = new WebAPIResult(); // Create the Http Request Message using (var request = new HttpRequestMessage(httpMethod, URL)) { // Add the access token and specify that the return value is required in JSON format request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // For OAuth2, Bearer Token based APIs request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authBearerToken); if (!string.IsNullOrEmpty(headerKeyName) && !string.IsNullOrEmpty(headerKeyValue)) { request.Headers.Add(headerKeyName, headerKeyValue); } //If the contentBody != "", attach it if (contentBody != "") { request.Content = new StringContent(contentBody, Encoding.UTF8, "application/json"); request.Content.Headers.ContentLength = contentBody.Length; } using (var response = await HTTPConnection.SendAsync(request)) { //LoggerService.Debug("Response Status: " + response.StatusCode); result.ReponseCode = response.StatusCode; result.ReponseContent = await response.Content.ReadAsStringAsync(); } //Check to see if there are exceptions thrown from the Web API, thrown an exception if (generateException && (result.ReponseCode != HttpStatusCode.OK) && (result.ReponseCode != HttpStatusCode.Created) && (result.ReponseCode != HttpStatusCode.NoContent)) { if (!string.IsNullOrEmpty(result.ReponseContent)) { //Default Values string errorCode = result.ReponseCode.ToString(); string errorMessage = result.ReponseContent; //Body may not be a valid json try { // Get the error details from the SAP message JObject errorInfo = JObject.Parse(result.ReponseContent); errorCode = (string)errorInfo["error"]["code"]; errorMessage = (string)errorInfo["error"]["message"]; } catch { } var error = new WebAPIException(errorCode, errorMessage); throw error; } else { throw new WebAPIException(result.ReponseCode.ToString(), result.ReponseCode.ToString()); } } } return(result); }
private Autoya(string basePath = "") { // Debug.LogWarning("autoya initialize start. basePath:" + basePath); var isPlayer = false; if (Application.isPlaying) { isPlayer = true; // create game object for Autoya. var go = GameObject.Find("AutoyaMainthreadDispatcher"); if (go == null) { go = new GameObject("AutoyaMainthreadDispatcher"); this.mainthreadDispatcher = go.AddComponent <AutoyaMainthreadDispatcher>(); GameObject.DontDestroyOnLoad(go); } else { this.mainthreadDispatcher = go.GetComponent <AutoyaMainthreadDispatcher>(); } } else { // create editor runnner for Autoya. this.mainthreadDispatcher = new EditorUpdator(); } _autoyaFilePersistence = new FilePersistence(basePath); _notification = new Notifications(AutoyaMainthreadDispatcher.AddNativeObserver); _autoyaHttp = new HTTPConnection(); InitializeAppManifest(); // setup response handling. this.httpResponseHandlingDelegate = HttpResponseHandling; /* * endPoint -> AB -> OnBootLoop -> authentication. */ IEnumerator bootSequence() { // EndPointSelector initialize and update. { InitializeEndPointImplementation(); retryEndPointRequest: var failed = false; var cor = UpdateEndPoints(() => failed = true); var cont = cor.MoveNext(); if (cont) { yield return(null); while (cor.MoveNext()) { yield return(null); } } if (failed) { if (ShouldRetryEndPointGetRequestOrNot()) { goto retryEndPointRequest; } } } // initialize AB feature. { var cor = InitializeAssetBundleFeature(); var cont = cor.MoveNext(); if (cont) { yield return(null); while (cor.MoveNext()) { yield return(null); } } } // boot app loop. { var cor = OnBootApplication(); var cont = cor.MoveNext(); if (cont) { yield return(null); while (cor.MoveNext()) { yield return(null); } } } // check if first boot or not. { var cor = IsFirstBoot( isFirstBoot => { /* * start authentication. */ Authenticate( isFirstBoot, () => { /* * initialize purchase feature. */ if (isPlayer) { ReloadPurchasability(); } } ); } ); // run 1st loop for getting autoya instance. var cont = cor.MoveNext(); if (cont) { yield return(null); while (cor.MoveNext()) { yield return(null); } } } } mainthreadDispatcher.Commit(bootSequence()); }
/* * public virtual void SessionModified(HTTPSession session, string key, object oldValue, object newValue) * { * * } * * public virtual void SessionExpired(HTTPSession session) * { * * } */ public abstract AsyncReply <bool> Execute(HTTPConnection sender);