[MTest] public void AutoyaHTTPGetFailWithUnauth() { var unauthorized = false; /* * dummy server returns 401 forcibly. */ Autoya.Http_Get( "https://httpbin.org/status/401", (string conId, string resultData) => { // do nothing. Debug.Log("Http_Get a resultData:" + resultData); }, (conId, code, reason, autoyaStatus) => { unauthorized = autoyaStatus.isAuthFailed; } ); WaitUntil( () => unauthorized, 5 ); // token refresh feature is already running. wait end. WaitUntil( () => Autoya.Auth_IsAuthenticated(), 5, "failed to refresh token." ); }
[MTest] public void HandleTokenRefreshFailed() { Autoya.forceFailTokenRefresh = true; var tokenRefreshFailed = false; Autoya.Auth_SetOnRefreshAuthFailed( (code, reason) => { tokenRefreshFailed = true; } ); // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (string conId, string resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // do nothing. } ); WaitUntil( () => tokenRefreshFailed, 10, "failed to handle tokenRefreshFailed." ); Autoya.forceFailTokenRefresh = false; }
[MTest] public void UnauthorizedThenHttpGet() { var reauthenticationSucceeded = false; // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // these handler will be fired automatically. Autoya.Auth_SetOnAuthenticated( () => { Autoya.Http_Get( "https://httpbin.org/get", (conId2, data2) => { reauthenticationSucceeded = true; }, (conId2, code2, reason2, autoyaStatus2) => { // do nothing. } ); } ); } ); WaitUntil( () => reauthenticationSucceeded, 10, "failed to handle SetOnAuthenticated." ); }
public IEnumerator SetOnMaintenance() { /* * ready for handle maintenance mode. * you can set the method which will be called on maintenance. */ Autoya.Maintenance_SetOnMaintenance( MyOnMaintenance ); // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // do nothing. } ); yield return(WaitUntil(() => onMaintenanceCalled, () => { throw new TimeoutException("onMaintenanceCalled does not be called."); })); }
[MTest] public void AutoyaHTTPGetFailWithTimeout() { var failedCode = -1; var timeoutError = string.Empty; /* * fake server should be response in 1msec. * server responses 1 sec later. * it is impossible. */ Autoya.Http_Get( "https://httpbin.org/delay/1", (string conId, string resultData) => { Assert(false, "got success result."); }, (conId, code, reason, autoyaStatus) => { failedCode = code; timeoutError = reason; }, null, 0.0001 ); WaitUntil( () => { return(!string.IsNullOrEmpty(timeoutError)); }, 3 ); Assert(failedCode == BackyardSettings.HTTP_TIMEOUT_CODE, "unmatch. failedCode:" + failedCode + " message:" + timeoutError); }
public IEnumerator HandleTokenRefreshFailed() { Autoya.forceFailTokenRefresh = true; var tokenRefreshFailed = false; Autoya.Auth_SetOnRefreshAuthFailed( (code, reason) => { tokenRefreshFailed = true; } ); // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // do nothing. } ); yield return(WaitUntil( () => tokenRefreshFailed, () => { throw new TimeoutException("failed to handle tokenRefreshFailed."); }, 20 )); Autoya.forceFailTokenRefresh = false; }
public IEnumerator AutoyaHTTPGetFailWithUnauth() { Autoya.forceSetHttpCodeAsUnauthorized = true; var unauthorized = false; /* * dummy server returns 401 forcibly. */ Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { Fail("never succeed."); }, (conId, code, reason, autoyaStatus) => { unauthorized = autoyaStatus.isAuthFailed; Autoya.forceSetHttpCodeAsUnauthorized = false; } ); yield return(WaitUntil( () => unauthorized, () => { throw new TimeoutException("timeout."); } )); // token refresh feature is already running. wait end. yield return(WaitUntil( () => Autoya.Auth_IsAuthenticated(), () => { throw new TimeoutException("failed to refresh token."); } )); }
public IEnumerator AutoyaHTTPGetFailWithTimeout() { var failedCode = -1; var timeoutError = string.Empty; /* * fake server should be response in 1msec. * server responses 1 sec later. * it is impossible. */ Autoya.Http_Get( "https://httpbin.org/delay/1", (conId, resultData) => { True(false, "got success result."); }, (conId, code, reason, autoyaStatus) => { failedCode = code; timeoutError = reason; }, null, 0.0001 ); yield return(WaitUntil( () => { return !string.IsNullOrEmpty(timeoutError); }, () => { throw new TimeoutException("timeout."); } )); True(failedCode == BackyardSettings.HTTP_TIMEOUT_CODE, "unmatch. failedCode:" + failedCode + " message:" + timeoutError); }
public IEnumerator ReceiveAppUpdate() { var done = false; Autoya.Debug_SetOverridePoint_OnNewAppRequested( newAppVer => { done = true; } ); Autoya.Http_Get( "https://httpbin.org/response-headers?appversion=1.0.1", (conId, data) => { done = true; }, (conid, code, reason, autoyaStatus) => { } ); yield return(WaitUntil( () => done, () => { throw new TimeoutException("too late"); } )); }
// Use this for initialization IEnumerator Start() { while (!Autoya.Auth_IsAuthenticated()) { yield return(null); } var connectionId1 = Autoya.Http_Get( "https://httpbin.org/get", // url (conId, data) => { // on succeeded Debug.Log("get data:" + data); }, (conId, code, reason, autoyaStatus) => { // on failed Debug.LogError("code:" + code + " reason:" + reason); }, new Dictionary <string, string>(), // headers 3.0 // timeout ); Debug.Log("start get with connectionId:" + connectionId1); var postData = "hello world."; var connectionId2 = Autoya.Http_Post( "https://httpbin.org/post", postData, (conId, resultData) => { Debug.Log("post data:" + resultData); }, (conId, code, reason, autoyaStatus) => { Debug.LogError("code:" + code + " reason:" + reason); } ); Debug.Log("start post with connectionId:" + connectionId2); }
public IEnumerator UpdateMultipleListAtOnce() { yield return(DownloadMultipleBundleListAtOnce()); // main_assetsは1.1、sub_assetsは2.0がサーバ上にある。 // 1.0.1 リストの更新判断の関数をセット var listContainsUsingAssetsAndShouldBeUpdateCount = 0; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (basePath, identity, ver) => { var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json"; return(Autoya.ShouldRequestOrNot.Yes(url)); } ); Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( condition => { if (condition == Autoya.CurrentUsingBundleCondition.NoUsingAssetsChanged) { listContainsUsingAssetsAndShouldBeUpdateCount++; } return(true); } ); // 1.0.1、2.0.0 リストを取得 Autoya.Http_Get( "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1,sub_assets:2.0.0", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return(WaitUntil( () => listContainsUsingAssetsAndShouldBeUpdateCount == 2, () => { throw new TimeoutException("failed to get response."); }, 10 )); True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1"); True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "sub_assets").FirstOrDefault().version == "2.0.0"); }
IEnumerator Start() { var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); while (!authenticated) { yield return(null); } // test method for set fake maintenance mode. Autoya.forceMaintenance = true; /* * ready for handle maintenance mode. * you can set the method which will be called on maintenance. */ Autoya.Maintenance_SetOnMaintenance( MyOnMaintenance ); // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { /* * you can check if service is in maintenance mode or not from autoyaStatus. */ var isUnderMaintenance = autoyaStatus.inMaintenance; Debug.Log("connection failed by maintenance:" + isUnderMaintenance); // reset for end test. Autoya.forceMaintenance = false; } ); }
[MTest] public void Maintenance() { var isUnderMaintenance = false; // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { isUnderMaintenance = autoyaStatus.inMaintenance; } ); WaitUntil(() => isUnderMaintenance, 5, "not in maintenance."); }
[MTest] public void AutoyaHTTPGet() { var result = string.Empty; Autoya.Http_Get( "https://httpbin.org/get", (string conId, string resultData) => { result = "done!:" + resultData; }, (conId, code, reason, autoyaStatus) => { Assert(false, "failed. code:" + code + " reason:" + reason); } ); WaitUntil( () => !string.IsNullOrEmpty(result), 5 ); }
public IEnumerator Maintenance() { var isUnderMaintenance = false; // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { isUnderMaintenance = autoyaStatus.inMaintenance; } ); yield return(WaitUntil(() => isUnderMaintenance, () => { throw new TimeoutException("not in maintenance."); })); }
public IEnumerator AutoyaHTTPGet() { var result = string.Empty; Autoya.Http_Get( "https://httpbin.org/get", (conId, resultData) => { result = "done!:" + resultData; }, (conId, code, reason, autoyaStatus) => { True(false, "failed. code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => !string.IsNullOrEmpty(result), () => { throw new TimeoutException("timeout."); } )); }
[MTest] public void AutoyaHTTPGetFailWith404() { var resultCode = 0; Autoya.Http_Get( "https://httpbin.org/status/404", (conId, resultData) => { Assert(false, "unexpected succeeded. resultData:" + resultData); }, (conId, code, reason, autoyaStatus) => { resultCode = code; } ); WaitUntil( () => (resultCode != 0), 5 ); // result should be have reason, Assert(resultCode == 404, "code unmatched. resultCode:" + resultCode); }
public IEnumerator UnauthorizedThenHttpGet() { var reauthenticationSucceeded = false; // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // these handler will be fired automatically. Autoya.Auth_SetOnAuthenticated( () => { Autoya.Http_Get( "https://httpbin.org/get", (string conId2, string data2) => { reauthenticationSucceeded = true; }, (conId2, code2, reason2, autoyaStatus2) => { // do nothing. } ); } ); } ); yield return(WaitUntil( () => reauthenticationSucceeded, () => { throw new TimeoutException("failed to handle SetOnAuthenticated."); }, 10 )); }
[MTest] public void AutoyaHTTPGetWithAdditionalHeader() { var result = string.Empty; Autoya.Http_Get( "https://httpbin.org/headers", (conId, resultData) => { result = resultData; }, (conId, code, reason, autoyaStatus) => { Assert(false, "failed. code:" + code + " reason:" + reason); }, new Dictionary <string, string> { { "Hello", "World" } } ); WaitUntil( () => (result.Contains("Hello") && result.Contains("World")), 5 ); }
[MTest] public void SetOnMaintenance() { /* * ready for handle maintenance mode. * you can set the method which will be called on maintenance. */ Autoya.Maintenance_SetOnMaintenance( MyOnMaintenance ); // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // do nothing. } ); WaitUntil(() => onMaintenanceCalled, 5, "onMaintenanceCalled does not be called."); }
public IEnumerator AutoyaHTTPGetFailWith404() { var resultCode = 0; Autoya.Http_Get( "https://httpbin.org/status/404", (conId, resultData) => { True(false, "unexpected succeeded. resultData:" + resultData); }, (conId, code, reason, autoyaStatus) => { resultCode = code; } ); yield return(WaitUntil( () => (resultCode != 0), () => { throw new TimeoutException("timeout."); } )); // result should be have reason, True(resultCode == 404, "code unmatched. resultCode:" + resultCode); }
public IEnumerator AutoyaHTTPGetWithAdditionalHeader() { var result = string.Empty; Autoya.Http_Get( "https://httpbin.org/headers", (conId, resultData) => { result = resultData; }, (conId, code, reason, autoyaStatus) => { True(false, "failed. code:" + code + " reason:" + reason); }, new Dictionary <string, string> { { "Hello", "World" } } ); yield return(WaitUntil( () => (result.Contains("Hello") && result.Contains("World")), () => { throw new TimeoutException("timeout."); } )); }
public IEnumerator ReceiveUpdatedListThenOnAssetBundleListUpdatedFired() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListFromUrlManually( abListPath + "main_assets/" + AssetBundlesSettings.PLATFORM_STR + "/1.0.0/main_assets.json", status => { done = true; }, (code, reason, autoyaStatus) => { // do nothing. } ); yield return WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } ); // リスト1.0.0が保持されている。 // 通信のレスポンスヘッダーに特定の値が含まれていることで、listの更新リクエストを送り出す機構を着火する。 // 新しいリストの取得判断の関数をセット(レスポンスを捕まえられるはず) Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (identity, newVersion) => { True(newVersion == "1.0.1"); return RequestYes(identity, newVersion); } ); // リストの更新判断の関数をセット var isListUpdated = false; Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( (condition, proceed, cancel) => { proceed(); } ); Autoya.Debug_SetOnOverridePoint_OnAssetBundleListUpdated( (newVersion, ready) => { ready(); isListUpdated = true; } ); Autoya.Http_Get( "https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return WaitUntil( () => isListUpdated, () => { throw new TimeoutException("too late."); } ); // list is updated. True(Autoya.AssetBundle_AssetBundleLists()[0].version == "1.0.1"); True(Autoya.Debug_AssetBundle_FeatureState() == Autoya.AssetBundlesFeatureState.Ready); }
public IEnumerator ReceiveListUpdated() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListFromUrlManually( abListPath + "main_assets/" + AssetBundlesSettings.PLATFORM_STR + "/1.0.0/main_assets.json", status => { done = true; }, (code, reason, autoyaStatus) => { // do nothing. Fail("code:" + code + " reason:" + reason); } ); yield return WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } ); // リスト1.0.0が保持されている。 // 通信のレスポンスヘッダーに特定の値が含まれていることで、listの更新リクエストを送り出す機構を着火する。 // 新しいリストの取得判断の関数をセット(レスポンスを捕まえられるはず) var listWillBeDownloaded = false; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (identity, newVersion) => { listWillBeDownloaded = true; True(newVersion == "1.0.1"); return RequestYes(identity, newVersion); } ); // リストの更新判断の関数をセット var listWillBeUpdated = false; Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( (condition, proceed, cancel) => { listWillBeUpdated = true; proceed(); } ); // この通信でresponseHeaderを指定してリストの更新機能を着火する。 Autoya.Http_Get( "https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return WaitUntil( () => listWillBeDownloaded, () => { throw new TimeoutException("too late."); } ); yield return WaitUntil( () => listWillBeUpdated, () => { throw new TimeoutException("too late."); } ); }
public IEnumerator UpdateListWithOnMemoryAssets() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( status => { done = true; }, (code, reason, asutoyaStatus) => { Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } )); True(Autoya.AssetBundle_IsAssetBundleFeatureReady()); UnityEngine.Object[] loadedAssets = null; // 全てのABをロード yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; })); True(loadedAssets != null); // 1.0.1 リストの更新判断の関数をセット var listContainsUsingAssetsAndShouldBeUpdate = false; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (basePath, identity, ver) => { var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json"; return(Autoya.ShouldRequestOrNot.Yes(url)); } ); Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( condition => { if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged) { listContainsUsingAssetsAndShouldBeUpdate = true; } return(true); } ); // 1.0.1リストを取得 Autoya.Http_Get( "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return(WaitUntil( () => listContainsUsingAssetsAndShouldBeUpdate, () => { throw new TimeoutException("failed to get response."); }, 10 )); True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1"); // load状態のAssetはそのまま使用できる for (var i = 0; i < loadedAssets.Length; i++) { var loadedAsset = loadedAssets[i]; True(loadedAsset != null); } }
public IEnumerator UpdateListWithOnMemoryAssetsThenReloadChangedAsset() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( status => { done = true; }, (code, reason, asutoyaStatus) => { Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } )); True(Autoya.AssetBundle_IsAssetBundleFeatureReady()); UnityEngine.Object[] loadedAssets = null; // 全てのABをロード yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; })); True(loadedAssets != null); var guidsDict = loadedAssets.ToDictionary( a => a.name, a => a.GetInstanceID() ); // 1.0.1 リストの更新判断の関数をセット var listContainsUsingAssetsAndShouldBeUpdate = false; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (basePath, identity, ver) => { var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json"; return(Autoya.ShouldRequestOrNot.Yes(url)); } ); Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( condition => { if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged) { listContainsUsingAssetsAndShouldBeUpdate = true; } return(true); } ); // 1.0.1リストを取得 Autoya.Http_Get( "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail("code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => listContainsUsingAssetsAndShouldBeUpdate, () => { throw new TimeoutException("failed to get response."); }, 10 )); True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1"); // 再度ロード済みのAssetをLoadしようとすると、更新があったABについて最新を取得してくる。 UnityEngine.Object[] loadedAssets2 = null; yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets2 = objs; })); var newGuidsDict = loadedAssets2.ToDictionary( a => a.name, a => a.GetInstanceID() ); var changedAssetCount = 0; foreach (var newGuidItem in newGuidsDict) { var name = newGuidItem.Key; var guid = newGuidItem.Value; if (guidsDict[name] != guid) { changedAssetCount++; } } True(changedAssetCount == 1); }
public IEnumerator UpdateListWithOnMemoryAssetsThenPreloadLoadedChangedAsset() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( status => { done = true; }, (code, reason, asutoyaStatus) => { Fail("UpdateListWithOnMemoryAssets failed, code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } )); True(Autoya.AssetBundle_IsAssetBundleFeatureReady()); UnityEngine.Object[] loadedAssets = null; // 全てのABをロード yield return(LoadAllAssetBundlesOfMainAssets(objs => { loadedAssets = objs; })); True(loadedAssets != null); // var guids = loadedAssets.Select(a => a.GetInstanceID()).ToArray(); var loadedAssetBundleNames = Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().assetBundles.Select(a => a.bundleName).ToArray(); // 1.0.1 リストの更新判断の関数をセット var listContainsUsingAssetsAndShouldBeUpdate = false; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (basePath, identity, ver) => { var url = basePath + identity + "/" + AssetBundlesSettings.PLATFORM_STR + "/" + ver + "/" + identity + ".json"; return(Autoya.ShouldRequestOrNot.Yes(url)); } ); Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( condition => { if (condition == Autoya.CurrentUsingBundleCondition.UsingAssetsAreChanged) { listContainsUsingAssetsAndShouldBeUpdate = true; } return(true); } ); // 1.0.1リストを取得 Autoya.Http_Get( "https://httpbin.org/response-headers?" + AuthSettings.AUTH_RESPONSEHEADER_RESVERSION + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return(WaitUntil( () => listContainsUsingAssetsAndShouldBeUpdate, () => { throw new TimeoutException("failed to get response."); }, 10 )); True(Autoya.AssetBundle_AssetBundleLists().Where(list => list.identity == "main_assets").FirstOrDefault().version == "1.0.1"); // preload all. var preloadDone = false; var preloadList = new PreloadList("dummy", loadedAssetBundleNames); Autoya.AssetBundle_PreloadByList( preloadList, (preloadCandidateBundleNames, go, stop) => { // all assetBundles should not be download. on memory loaded ABs are not updatable. True(preloadCandidateBundleNames.Length == 0); go(); }, progress => { }, () => { preloadDone = true; }, (code, reason, status) => { Fail("code:" + code + " reason:" + reason); }, (failedAssetBundleName, code, reason, status) => { Fail("failedAssetBundleName:" + failedAssetBundleName + " code:" + code + " reason:" + reason); }, 5 ); yield return(WaitUntil( () => preloadDone, () => { throw new TimeoutException("failed to preload."); }, 10 )); }
public IEnumerator ReceiveUpdatedListThenIgnoreAndIgnoredListIsCached() { var done = false; Autoya.AssetBundle_DownloadAssetBundleListFromUrlManually( abListPath + "main_assets/" + AssetBundlesSettings.PLATFORM_STR + "/1.0.0/main_assets.json", status => { done = true; }, (code, reason, autoyaStatus) => { // do nothing. } ); yield return WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } ); // リスト1.0.0が保持されている。 // 通信のレスポンスヘッダーに特定の値が含まれていることで、listの更新リクエストを送り出す機構を着火する。 // 新しいリストの取得判断の関数をセット(レスポンスを捕まえられるはず) Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (identity, newVersion) => { True(newVersion == "1.0.1"); return RequestYes(identity, newVersion); } ); // リストの更新判断の関数をセット、ここでは更新を無視する。 // 無視されたリストはpostponedなリストとしてメモリ上に保持される。これによって無駄な取得リクエストを省く。 var listWillBeIgnored = false; Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( (condition, proceed, cancel) => { listWillBeIgnored = true; cancel(); } ); Autoya.Http_Get( "https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return WaitUntil( () => listWillBeIgnored, () => { throw new TimeoutException("too late."); } ); // list is not updated yet. True(Autoya.AssetBundle_AssetBundleLists()[0].version == "1.0.0"); True(Autoya.Debug_AssetBundle_FeatureState() == Autoya.AssetBundlesFeatureState.Ready); // set to the new list to be updated. var listWillBeUpdated = false; Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( (condition, proceed, cancel) => { listWillBeUpdated = true; proceed(); } ); // get list again. Autoya.Http_Get( "https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return WaitUntil( () => listWillBeUpdated, () => { throw new TimeoutException("too late."); } ); True(Autoya.AssetBundle_AssetBundleLists()[0].version == "1.0.1"); }
public IEnumerator ReceiveUpdatedListThenIgnore() { var done = false; Autoya.Debug_AssetBundle_DownloadAssetBundleListFromUrl( abListPath + "main_assets/" + AssetBundlesSettings.PLATFORM_STR + "/1.0.0/main_assets.json", status => { done = true; }, (code, reason, autoyaStatus) => { // do nothing. } ); yield return(WaitUntil( () => done, () => { throw new TimeoutException("faild to get assetBundleList."); } )); // リスト1.0.0が保持されている。 // 通信のレスポンスヘッダーに特定の値が含まれていることで、listの更新リクエストを送り出す機構を着火する。 // 新しいリストの取得判断の関数をセット(レスポンスを捕まえられるはず) var listWillBeDownloaded = false; Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList( (basePath, identity, newVersion) => { listWillBeDownloaded = true; True(newVersion == "1.0.1"); return(RequestYes(basePath, identity, newVersion)); } ); // リストの更新判断の関数をセット、ここでは更新を無視する。 var listWillBeIgnored = false; Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList( condition => { listWillBeIgnored = true; return(false); } ); Autoya.Http_Get( "https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1", (conId, data) => { // pass. }, (conId, code, reason, status) => { Fail(); } ); yield return(WaitUntil( () => listWillBeDownloaded, () => { throw new TimeoutException("too late."); } )); yield return(WaitUntil( () => listWillBeIgnored, () => { throw new TimeoutException("too late."); } )); // list is not updated yet. True(Autoya.AssetBundle_AssetBundleLists()[0].version == "1.0.0"); True(Autoya.Debug_AssetBundle_FeatureState() == Autoya.AssetBundlesFeatureState.Ready); }
public IEnumerator AvoidHttpAuthFailCascade() { Autoya.forceFailAuthentication = true; var retryActs = new List <Action>(); Action authDoneAct = () => { retryActs.ForEach(r => r()); retryActs.Clear(); }; Autoya.Auth_SetOnAuthenticated(authDoneAct); var conCount = 10; var doneConIds = new List <string>(); var onceFailed = new List <string>(); var connections = new List <Action>(); for (var i = 0; i < conCount; i++) { var index = i; var currentConId = i.ToString(); connections.Add( () => { Autoya.Http_Get( "https://httpbin.org/status/200", (conId, resultData) => { doneConIds.Add(conId); }, (conId, code, reason, autoyaStatus) => { if (autoyaStatus.isAuthFailed) { onceFailed.Add(conId); retryActs.Add(connections[index]); } }, null, 5, currentConId ); } ); } // 通信の全てが行われればOK foreach (var act in connections) { act(); } // once failed. yield return(WaitUntil( () => onceFailed.Count == conCount, () => { throw new TimeoutException("too late."); }, 10 )); // refreshの完全なfailまでには8秒以上あるので、ここでフラグを変更しても十分にリトライに間に合うはず Autoya.forceFailAuthentication = false; // once failed. yield return(WaitUntil( () => doneConIds.Count == conCount, () => { throw new TimeoutException("too late."); }, 10 )); }