/** リクエスト。ロードURL。テクスチャファイル。 */ public void RequestLoadUrlTextureFile(Path a_url_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { this.request_type = RequestType.LoadUrlTextureFile; this.request_path = a_url_path; this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; }
/** リクエスト。ロードストリーミングアセット。サウンドプール。 */ public bool RequestLoadStreamingAssetsSoundPool(Fee.File.Path a_path, uint a_data_version) { if (this.is_busy == false) { this.is_busy = true; //is_cancel this.is_cancel = false; //request this.request_path = a_path; this.request_post_data = null; this.request_certificate_handler = null; this.request_data_version = a_data_version; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_soundpool = null; this.result_responseheader = null; Function.Function.StartCoroutine(this.DoLoadStreamingAssetsSoundPool()); return(true); } return(false); }
/** リクエスト。ロードURL。テクスチャファイル。 */ public bool RequestLoadUrlTextureFile(Path a_url_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { if (this.is_busy == false) { this.is_busy = true; //is_cancel this.is_cancel = false; //request this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; this.request_path = a_url_path; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_asset = null; this.result_responseheader = null; Function.Function.StartCoroutine(this.DoLoadUrlTextureFile()); return(true); } return(false); }
/** リクエスト。ロードストリーミングアセット。テクスチャファイル。 */ public bool RequestLoadStreamingAssetsTextureFile(Path a_relative_path) { if (this.is_busy == false) { this.is_busy = true; //is_cancel this.is_cancel = false; //request this.request_post_data = null; this.request_certificate_handler = null; this.request_path = a_relative_path; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_asset = null; this.result_responseheader = null; Function.Function.StartCoroutine(this.DoLoadStreamingAssetsTextureFile()); return(true); } return(false); }
/** リクエスト。ロードURL。テクスチャファイル。 */ public void RequestLoadUrlTextureFile(Path a_url_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { this.request_type = RequestType.LoadUrlTextureFile; this.request_path = a_url_path; this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; }
/** constructor */ public WorkItem() { //mode this.mode = Mode.Start; //request_type this.request_type = RequestType.None; //request_path this.request_path = null; //request_post_data this.request_post_data = null; //request_certificate_handler this.request_certificate_handler = null; //request_binary this.request_binary = null; //request_text this.request_text = null; //request_texture this.request_texture = null; //item this.item = new Item(); }
/** リクエスト。ロードURL。パック。 */ public bool RequestLoadUrlPack(File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, uint a_data_version) { if (this.is_busy == false) { this.is_busy = true; //is_cancel this.is_cancel = false; //request this.request_path = a_path; this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; this.request_data_version = a_data_version; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_pack = null; this.result_responseheader = null; Function.Function.GetInstance().StartCoroutine(this.DoLoadUrlPack()); return(true); } return(false); }
/** リクエスト。ロードローカル。パック。 */ public bool RequestLoadLocalPack(File.Path a_path) { if (this.is_busy == false) { this.is_busy = true; //is_cancel this.is_cancel = false; //request this.request_path = a_path; this.request_post_data = null; this.request_certificate_handler = null; this.request_data_version = 0; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_pack = null; this.result_responseheader = null; Function.Function.GetInstance().StartCoroutine(this.DoLoadLocalPack()); return(true); } return(false); }
/** リクエスト。ロードURL。サウンドプール。 */ public void RequestLoadUrlBinaryFile(File.Path a_url_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, uint a_data_version) { this.request_type = RequestType.LoadUrlSoundPool; this.request_path = a_url_path; this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; this.request_data_version = a_data_version; }
/** リクエスト。ロードURL。パック。 */ public void RequestLoadUrlBinaryFile(File.Path a_url_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, uint a_data_version) { this.request_type = RequestType.LoadUrlPack; this.request_path = a_url_path; this.request_post_data = a_post_data; this.request_certificate_handler = a_certificate_handler; this.request_data_version = a_data_version; }
/** constructor */ public Main_WebRequest() { this.is_busy = false; this.is_cancel = false; this.is_shutdown = false; //request this.request_post_data = null; this.request_certificate_handler = null; this.request_path = null; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_asset = null; this.result_responseheader = null; }
/** constructor */ public Main_File() { this.is_busy = false; this.is_cancel = false; this.is_shutdown = false; //request this.request_path = null; this.request_post_data = null; this.request_certificate_handler = null; this.request_data_version = 0; //result this.result_progress = 0.0f; this.result_errorstring = null; this.result_type = ResultType.None; this.result_soundpool = null; this.result_responseheader = null; }
/** constructor */ public WorkItem() { //mode this.mode = Mode.Start; //request_type this.request_type = RequestType.None; //request_path this.request_path = null; //request_post_data this.request_post_data = null; //request_certificate_handler this.request_certificate_handler = null; //request_data_version this.request_data_version = 0; //item this.item = new Item(); }
/** RequestLoadUrl */ public Item RequestLoadUrl(LoadRequestType a_request_type, Path a_path, UnityEngine.WWWForm a_post_data = null, Fee.File.CustomCertificateHandler a_certificate_handler = null) { switch (a_request_type) { //ロードURL。 case LoadRequestType.LoadUrlBinaryFile: { WorkItem t_work_item = new WorkItem(); t_work_item.RequestLoadUrlBinaryFile(a_path, a_post_data, a_certificate_handler); this.add_list.Add(t_work_item); return(t_work_item.GetItem()); } break; case LoadRequestType.LoadUrlTextFile: { WorkItem t_work_item = new WorkItem(); t_work_item.RequestLoadUrlTextFile(a_path, a_post_data, a_certificate_handler); this.add_list.Add(t_work_item); return(t_work_item.GetItem()); } break; case LoadRequestType.LoadUrlTextureFile: { WorkItem t_work_item = new WorkItem(); t_work_item.RequestLoadUrlTextureFile(a_path, a_post_data, a_certificate_handler); this.add_list.Add(t_work_item); return(t_work_item.GetItem()); } break; } Tool.Assert(false); return(null); }
/** CoroutineMain */ public System.Collections.IEnumerator CoroutineMain(OnSoundPoolCoroutine_CallBackInterface a_callback_interface, File.Path a_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, bool a_is_streamingassets, uint a_data_version) { //result this.result = new ResultType(); Fee.Pattern.Progress t_progress = new Fee.Pattern.Progress(new float[] { 0.05f, 0.1f, 0.8f, 0.05f }); //ローカル、サウンロプール管理ファイル。相対パス。 Fee.File.Path t_local_caoundpool_path = new File.Path(a_path.GetFileName()); //ローカル、サウンドプール管理ファイルのロード。 Fee.JsonItem.JsonItem t_local_soundpool_json = null; if (Config.USE_LOADURL_SOUNDPOOL_CACHE == true) { Fee.File.Item t_item = Fee.File.File.GetInstance().RequestLoad(File.File.LoadRequestType.LoadLocalTextFile, t_local_caoundpool_path); do { //■ステップ0。 if (a_callback_interface != null) { t_progress.SetStep((int)Progress_MainStep.Progress_MainStep_0_LoadLocal_SoundPool, 0, 1); a_callback_interface.OnSoundPoolCoroutine(t_progress.CalcProgress(t_item.GetResultProgress())); } yield return(null); }while(t_item.IsBusy() == true); if (t_item.GetResultAssetType() == Asset.AssetType.Text) { t_local_soundpool_json = new JsonItem.JsonItem(t_item.GetResultAssetText()); if (t_local_soundpool_json == null) { //コンバート失敗。 this.result.errorstring = "Coroutine_LoadSoundPool : local_soundpool_json == null"; yield break; } } else { //ローカルにキャッシュなし。 } } //チェック。 if (t_local_soundpool_json != null) { if ((t_local_soundpool_json.IsAssociativeArray() == true) && (t_local_soundpool_json.IsExistItem("data_version"))) { uint t_data_version = t_local_soundpool_json.GetItem("data_version").CastToUint16(); if (t_data_version == a_data_version) { Fee.Audio.Pack_SoundPool t_local_soundpool = Fee.JsonItem.Convert.JsonItemToObject <Fee.Audio.Pack_SoundPool>(t_local_soundpool_json); if (t_local_soundpool != null) { //最新を取得する必要なし。 //パス解決。 { t_local_soundpool.fullpath_list = new System.Collections.Generic.List <File.Path>(); for (int ii = 0; ii < t_local_soundpool.name_list.Count; ii++) { t_local_soundpool.fullpath_list.Add(File.Path.CreateLocalPath(t_local_soundpool.name_list[ii])); } } this.result.soundpool = t_local_soundpool; this.result.responseheader = null; yield break; } else { //コンバート失敗。 } } else { //最新のバージョンが必要。 } } else { //不明なデータ。 } t_local_soundpool_json = null; } //ロード。 string t_load_stringjson = null; Fee.Audio.Pack_SoundPool t_load_soundpool = null; //サウンドプール管理ファイルのロード。 { Fee.File.Item t_item = null; if (a_is_streamingassets == true) { t_item = Fee.File.File.GetInstance().RequestLoad(File.File.LoadRequestType.LoadStreamingAssetsTextFile, a_path); } else { t_item = Fee.File.File.GetInstance().RequestLoadUrl(File.File.LoadRequestType.LoadUrlTextFile, a_path, a_post_data, a_certificate_handler); } do { //■ステップ1。 if (a_callback_interface != null) { t_progress.SetStep((int)Progress_MainStep.Progress_MainStep_1_Load_SoundPool, 0, 1); a_callback_interface.OnSoundPoolCoroutine(t_progress.CalcProgress(t_item.GetResultProgress())); } yield return(null); }while(t_item.IsBusy() == true); this.result.responseheader = t_item.GetResultResponseHeader(); if (t_item.GetResultAssetType() == Asset.AssetType.Text) { //成功。 t_load_stringjson = t_item.GetResultAssetText(); } else { //失敗。 this.result.errorstring = t_item.GetResultErrorString(); yield break; } t_load_soundpool = JsonItem.Convert.JsonStringToObject <Fee.Audio.Pack_SoundPool>(t_load_stringjson); if (t_load_soundpool == null) { //コンバート失敗。 this.result.errorstring = "Coroutine_LoadSoundPool : load_soundpool == null"; yield break; } else if (t_load_soundpool.name_list == null) { //不明なデータ。 this.result.errorstring = "Coroutine_LoadSoundPool : load_soundpool.name_list == null"; yield break; } else if (t_load_soundpool.volume_list == null) { //不明なデータ。 this.result.errorstring = "Coroutine_LoadSoundPool : load_soundpool.volume_list == null"; yield break; } } //登録サウンドのロード。 { for (int ii = 0; ii < t_load_soundpool.name_list.Count; ii++) { byte[] t_sound_binary = null; //ロード。 { Fee.File.Path t_sound_url = a_path.CreateFileNameChangePath(t_load_soundpool.name_list[ii]); Fee.File.Item t_item = null; if (a_is_streamingassets) { t_item = Fee.File.File.GetInstance().RequestLoad(File.File.LoadRequestType.LoadStreamingAssetsBinaryFile, t_sound_url); } else { t_item = Fee.File.File.GetInstance().RequestLoad(File.File.LoadRequestType.LoadUrlBinaryFile, t_sound_url); } do { //■ステップ2。 if (a_callback_interface != null) { t_progress.SetStep((int)Progress_MainStep.Progress_MainStep_2_Sound, ii * 2 + 0, t_load_soundpool.name_list.Count * 2); a_callback_interface.OnSoundPoolCoroutine(t_progress.CalcProgress(t_item.GetResultProgress())); } yield return(null); }while(t_item.IsBusy() == true); if (t_item.GetResultAssetType() == Asset.AssetType.Binary) { //成功。 t_sound_binary = t_item.GetResultAssetBinary(); } else { //失敗。 this.result.errorstring = t_item.GetResultErrorString(); yield break; } } //セーブローカル。 { Fee.File.Path t_sound_url = new File.Path(t_load_soundpool.name_list[ii]); File.Item t_item = Fee.File.File.GetInstance().RequestSaveBinaryFile(File.File.SaveRequestType.SaveLocalBinaryFile, t_sound_url, t_sound_binary); do { //■ステップ2。 if (a_callback_interface != null) { t_progress.SetStep((int)Progress_MainStep.Progress_MainStep_2_Sound, ii * 2 + 1, t_load_soundpool.name_list.Count * 2); a_callback_interface.OnSoundPoolCoroutine(t_progress.CalcProgress(t_item.GetResultProgress())); } yield return(null); }while(t_item.IsBusy() == true); if (t_item.GetResultType() == File.Item.ResultType.SaveEnd) { //成功。 } else { //失敗。 this.result.errorstring = t_item.GetResultErrorString(); yield break; } } } } //ローカル、サウンドプール管理ファイルのセーブ。 { File.Item t_item = Fee.File.File.GetInstance().RequestSaveTextFile(File.File.SaveRequestType.SaveLocalTextFile, t_local_caoundpool_path, t_load_stringjson); do { //■ステップ3。 if (a_callback_interface != null) { t_progress.SetStep((int)Progress_MainStep.Progress_MainStep_3_SaveLocal_SoundPool, 0, 1); a_callback_interface.OnSoundPoolCoroutine(t_progress.CalcProgress(t_item.GetResultProgress())); } yield return(null); }while(t_item.IsBusy() == true); if (t_item.GetResultType() == File.Item.ResultType.SaveEnd) { //成功。 } else { //失敗。 this.result.errorstring = t_item.GetResultErrorString(); yield break; } } //パス解決。 { t_load_soundpool.fullpath_list = new System.Collections.Generic.List <File.Path>(); for (int ii = 0; ii < t_load_soundpool.name_list.Count; ii++) { t_load_soundpool.fullpath_list.Add(Fee.File.Path.CreateLocalPath(t_load_soundpool.name_list[ii])); } } this.result.soundpool = t_load_soundpool; yield break; }
/** CoroutineMain */ public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { //result this.result = null; //ロード。 byte[] t_result_binary = null; System.Collections.Generic.Dictionary <string, string> t_result_responseheader = null; long t_result_responsecode = 0; { using (UnityEngine.Networking.UnityWebRequest t_webrequest = CreateWebRequestInstance(a_path, a_post_data, a_certificate_handler)){ //通信。 { UnityEngine.Networking.UnityWebRequestAsyncOperation t_webrequest_async = null; if (t_webrequest != null) { t_webrequest_async = t_webrequest.SendWebRequest(); if (t_webrequest_async == null) { //エラー。 this.result = new ResultType(null, "Unknown Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } } else { //エラー。 this.result = new ResultType(null, "Unknown Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } do { //エラーチェック。 if (t_webrequest.result == UnityEngine.Networking.UnityWebRequest.Result.InProgress) { //実行中。 } else if (t_webrequest.result == UnityEngine.Networking.UnityWebRequest.Result.Success) { //正常終了。 yield return(t_webrequest_async); break; } else { //エラー。 if (t_webrequest.error != null) { this.result = new ResultType(null, "Connect Error : LoadUrlTextFile : " + a_path.GetPath() + " : " + t_webrequest.error, t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); } else { this.result = new ResultType(null, "Connect Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); } yield break; } //キャンセルチェック。 { if (a_callback_interface != null) { float t_progress = (t_webrequest.uploadProgress + t_webrequest.downloadProgress) / 2; if (a_callback_interface.OnFileCoroutine(t_progress) == false) { t_webrequest.Abort(); } } } yield return(null); }while(true); } //コンバート。 try{ if (t_webrequest.downloadHandler == null) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } byte[] t_result = t_webrequest.downloadHandler.data; if (t_result == null) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } t_result_binary = t_result; }catch (System.Exception t_exception) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath() + " : " + t_exception.Message, t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } //レスポンスヘッダー。 t_result_responseheader = t_webrequest.GetResponseHeaders(); t_result_responsecode = t_webrequest.responseCode; } } //コンバート。 string t_result_text = null; { string t_result = Fee.StringConvert.Utf8BinaryToString.Convert(t_result_binary, 0, t_result_binary.Length); if (t_result != null) { //成功。 t_result_text = t_result; } else { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_result_responseheader, t_result_responsecode); yield break; } } //成功。 this.result = new ResultType(t_result_text, null, t_result_responseheader, t_result_responsecode); yield break; }
/** CreateWebRequestInstance */ private static UnityEngine.Networking.UnityWebRequest CreateWebRequestInstance(Fee.File.Path a_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { UnityEngine.Networking.UnityWebRequest t_webrequest = null; if (a_post_data != null) { t_webrequest = UnityEngine.Networking.UnityWebRequest.Post(a_path.GetPath(), a_post_data); } else { t_webrequest = UnityEngine.Networking.UnityWebRequest.Get(a_path.GetPath()); } if (a_certificate_handler != null) { a_certificate_handler.InitializeCheck(); t_webrequest.certificateHandler = a_certificate_handler; } else { t_webrequest.certificateHandler = new Fee.File.CustomCertificateHandler(Fee.File.File.GetInstance().GetCertificateString(a_path.GetPath())); } return(t_webrequest); }
/** RequestLoadUrl */ public Item RequestLoadUrl(LoadRequestType a_request_type, Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data = null, Fee.File.CustomCertificateHandler a_certificate_handler = null) { switch (a_request_type) { //ロードURL。 case LoadRequestType.LoadUrlBinaryFile: { System.Collections.Generic.LinkedListNode <WorkItem> t_work_node = this.work_pool.Alloc(); t_work_node.Value.Reset(); t_work_node.Value.RequestLoadUrlBinaryFile(a_path, a_post_data, a_certificate_handler); this.work_add.AddLast(t_work_node); return(t_work_node.Value.GetItem()); } break; case LoadRequestType.LoadUrlTextFile: { System.Collections.Generic.LinkedListNode <WorkItem> t_work_node = this.work_pool.Alloc(); t_work_node.Value.Reset(); t_work_node.Value.RequestLoadUrlTextFile(a_path, a_post_data, a_certificate_handler); this.work_add.AddLast(t_work_node); return(t_work_node.Value.GetItem()); } break; case LoadRequestType.LoadUrlTextureFile: { System.Collections.Generic.LinkedListNode <WorkItem> t_work_node = this.work_pool.Alloc(); t_work_node.Value.Reset(); t_work_node.Value.RequestLoadUrlTextureFile(a_path, a_post_data, a_certificate_handler); this.work_add.AddLast(t_work_node); return(t_work_node.Value.GetItem()); } break; } Tool.Assert(false); return(null); }
/** リクエスト。ロードURL。パック。 * * ロード後ローカルセーブ。 * */ public Item RequestLoadUrlPack(File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, uint a_data_version) { System.Collections.Generic.LinkedListNode <WorkItem> t_work_node = this.work_pool.Alloc(); t_work_node.Value.Reset(); t_work_node.Value.RequestLoadUrlBinaryFile(a_path, a_post_data, a_certificate_handler, a_data_version); this.work_add.AddLast(t_work_node); return(t_work_node.Value.GetItem()); }
/** CreateWebRequestInstance */ private static UnityEngine.Networking.UnityWebRequest CreateWebRequestInstance(Fee.File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { UnityEngine.Networking.UnityWebRequest t_webrequest = null; if (a_post_data != null) { t_webrequest = UnityEngine.Networking.UnityWebRequest.Post(a_path.GetPath(), a_post_data); } else { t_webrequest = UnityEngine.Networking.UnityWebRequest.Get(a_path.GetPath()); } if (a_certificate_handler != null) { t_webrequest.certificateHandler = a_certificate_handler; } else { string t_certificate_string = Fee.File.File.GetInstance().GetCertificateString(a_path.GetPath()); if (t_certificate_string != null) { t_webrequest.certificateHandler = new Fee.File.CustomCertificateHandler(t_certificate_string); } } return(t_webrequest); }
/** リクエスト。ロードURL。サウンドプール。 * * ロード後ローカルセーブ。 * */ public Item RequestLoadUrlSoundPool(File.Path a_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler, uint a_data_version) { WorkItem t_work_item = new WorkItem(); t_work_item.RequestLoadUrlBinaryFile(a_path, a_post_data, a_certificate_handler, a_data_version); this.add_list.Add(t_work_item); return(t_work_item.GetItem()); }