|
@@ -1,9 +1,12 @@
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Net;
|
|
|
using ET;
|
|
|
+using FairyGUI;
|
|
|
using GFGGame;
|
|
|
-
|
|
|
+using UnityEngine;
|
|
|
+using UnityEngine.Networking;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -28,10 +31,7 @@ namespace GFGGame
|
|
|
photoData.LockingStatus = response.PictureInfosA[i].LockingStatus;
|
|
|
photoData.PictureName = response.PictureInfosA[i].PictureName;
|
|
|
photoData.PictureTempUrl = response.PictureInfosA[i].PictureTempUrl;
|
|
|
- byte[] bytes = DownloadFile(response.PictureInfosA[i].PictureTempUrl);
|
|
|
- photoData.Bytes = bytes;
|
|
|
- // photoData.Ntexture = PoemPhotoDataManager.Instance.BytesToTexture2D(bytes); ;
|
|
|
-
|
|
|
+ Timers.inst.StartCoroutine(DownloadFile(photoData));
|
|
|
PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.PersonalAlbum);
|
|
|
}
|
|
|
for (int i = 0; i < response.PictureInfosB.Count; i++)
|
|
@@ -44,10 +44,7 @@ namespace GFGGame
|
|
|
photoData.LockingStatus = response.PictureInfosB[i].LockingStatus;
|
|
|
photoData.PictureName = response.PictureInfosB[i].PictureName;
|
|
|
photoData.PictureTempUrl = response.PictureInfosB[i].PictureTempUrl;
|
|
|
- byte[] bytes = DownloadFile(response.PictureInfosB[i].PictureTempUrl);
|
|
|
- photoData.Bytes = bytes;
|
|
|
- // photoData.Ntexture = PoemPhotoDataManager.Instance.BytesToTexture2D(bytes); ;
|
|
|
-
|
|
|
+ Timers.inst.StartCoroutine(DownloadFile(photoData));
|
|
|
PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.WanShuiQianShan);
|
|
|
}
|
|
|
return true;
|
|
@@ -59,17 +56,13 @@ namespace GFGGame
|
|
|
//获取图片的临时上传地址协议
|
|
|
public static async ETTask<string[]> ReqTempPictureUrl(int pictureType)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya000");
|
|
|
S2C_GetTempPictureUrl response = null;
|
|
|
response = (S2C_GetTempPictureUrl)await MessageHelper.SendToServer(new C2S_GetTempPictureUrl() { PictureType = pictureType });
|
|
|
- ET.Log.Debug("zoya111");
|
|
|
|
|
|
if (response != null)
|
|
|
{
|
|
|
if (response.Error == ErrorCode.ERR_Success)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya222");
|
|
|
-
|
|
|
return new string[] { response.TempPictureUrl, response.PictureObjectPath };
|
|
|
}
|
|
|
}
|
|
@@ -79,7 +72,6 @@ namespace GFGGame
|
|
|
//将图片上传到华为云
|
|
|
public static string PushToHWCloud(string signUrl, byte[] buffer)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya333" + buffer);
|
|
|
|
|
|
// 使用PUT请求上传对象
|
|
|
HttpWebRequest webRequest = WebRequest.Create(signUrl) as HttpWebRequest;
|
|
@@ -96,33 +88,26 @@ namespace GFGGame
|
|
|
HttpWebResponse webResponse = null;
|
|
|
try
|
|
|
{
|
|
|
- ET.Log.Debug("zoya444");
|
|
|
-
|
|
|
webResponse = webRequest.GetResponse() as HttpWebResponse;
|
|
|
return webResponse.StatusCode.ToString();
|
|
|
}
|
|
|
catch (WebException ex)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya555");
|
|
|
-
|
|
|
webResponse = ex.Response as HttpWebResponse;
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
//保存成功后,添加图片至相册
|
|
|
- public static async ETTask<bool> ReqAddTophoto(string pictureObjectPath, int sourceType)
|
|
|
+ public static async ETTask<long> ReqAddTophoto(string pictureObjectPath, int sourceType)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya666");
|
|
|
|
|
|
S2C_AddPicture response = null;
|
|
|
response = (S2C_AddPicture)await MessageHelper.SendToServer(new C2S_AddPicture() { PictureObjectPath = pictureObjectPath, SourceType = sourceType });
|
|
|
- ET.Log.Debug("zoya777");
|
|
|
|
|
|
if (response != null)
|
|
|
{
|
|
|
if (response.Error == ErrorCode.ERR_Success)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya888");
|
|
|
|
|
|
PoemPhotoData photoData = new PoemPhotoData();
|
|
|
photoData.PictureId = response.PictureInfo.PictureId;
|
|
@@ -132,66 +117,58 @@ namespace GFGGame
|
|
|
photoData.LockingStatus = response.PictureInfo.LockingStatus;
|
|
|
photoData.PictureName = response.PictureInfo.PictureName;
|
|
|
photoData.PictureTempUrl = response.PictureInfo.PictureTempUrl;
|
|
|
- ET.Log.Debug("zoya999" + response.PictureInfo.PictureTempUrl);
|
|
|
-
|
|
|
- byte[] bytes = DownloadFile(photoData.PictureTempUrl);
|
|
|
- ET.Log.Debug("zoyafff");
|
|
|
- photoData.Bytes = bytes;
|
|
|
-
|
|
|
PoemPhotoDataManager.Instance.Add(photoData, sourceType);
|
|
|
- ET.Log.Debug("zoyajjj");
|
|
|
-
|
|
|
-
|
|
|
EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
|
|
|
PromptController.Instance.ShowFloatTextPrompt("已保存至相册");
|
|
|
- return true;
|
|
|
+ return response.PictureInfo.PictureId;
|
|
|
}
|
|
|
}
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
}
|
|
|
- public static byte[] DownloadFile(string URL)
|
|
|
+ public static IEnumerator DownloadFile(PoemPhotoData poemPhotoData)
|
|
|
{
|
|
|
- try
|
|
|
+ using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(poemPhotoData.PictureTempUrl))
|
|
|
{
|
|
|
- ET.Log.Debug("zoyaaaa" + URL);
|
|
|
-
|
|
|
- HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
|
|
- webRequest.Method = "GET";
|
|
|
- ET.Log.Debug("zoyabbb+Method:" + webRequest.Method);
|
|
|
-
|
|
|
- HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;
|
|
|
- ET.Log.Debug("zoyabbb" + webResponse);
|
|
|
-
|
|
|
- System.IO.Stream st = webResponse.GetResponseStream();
|
|
|
- ET.Log.Debug("zoyabbb+st:" + st);
|
|
|
-
|
|
|
- byte[] bytes;
|
|
|
- using (var ms = new MemoryStream())
|
|
|
- {
|
|
|
- st.CopyTo(ms);
|
|
|
- bytes = ms.ToArray();
|
|
|
- }
|
|
|
- ET.Log.Debug("zoyaccc");
|
|
|
-
|
|
|
- st.Close();
|
|
|
- webResponse.Close();
|
|
|
- webRequest.Abort();
|
|
|
- ET.Log.Debug("zoyaddd");
|
|
|
-
|
|
|
- return bytes;
|
|
|
+ yield return request.SendWebRequest();
|
|
|
+ Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
|
+ poemPhotoData.Ntexture = new NTexture(texture);
|
|
|
}
|
|
|
- catch (WebException ex)
|
|
|
- {
|
|
|
- ET.Log.Debug("zoyaeee");
|
|
|
-
|
|
|
- // webResponse = ex.Response as HttpWebResponse;
|
|
|
- ET.Log.Debug(ex.Response.ToString());
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+
|
|
|
+ // HttpWebRequest webRequest = HttpWebRequest.Create(poemPhotoData.PictureTempUrl) as HttpWebRequest;
|
|
|
+ // webRequest.Method = "GET";
|
|
|
+ // ET.Log.Debug("zoyabbb+Method:" + webRequest.Method);
|
|
|
+
|
|
|
+ // HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;
|
|
|
+ // ET.Log.Debug("zoyabbb" + webResponse);
|
|
|
+
|
|
|
+ // System.IO.Stream st = webResponse.GetResponseStream();
|
|
|
+ // ET.Log.Debug("zoyabbb+st:" + st);
|
|
|
+
|
|
|
+ // byte[] bytes;
|
|
|
+ // using (var ms = new MemoryStream())
|
|
|
+ // {
|
|
|
+ // st.CopyTo(ms);
|
|
|
+ // bytes = ms.ToArray();
|
|
|
+ // }
|
|
|
+ // ET.Log.Debug("zoyaccc");
|
|
|
+
|
|
|
+ // st.Close();
|
|
|
+ // webResponse.Close();
|
|
|
+ // webRequest.Abort();
|
|
|
+ // ET.Log.Debug("zoyaddd");
|
|
|
+ // poemPhotoData.Bytes = bytes;
|
|
|
+ // }
|
|
|
+ // catch (WebException ex)
|
|
|
+ // {
|
|
|
+ // ET.Log.Debug("zoyaeee");
|
|
|
+
|
|
|
+ // // webResponse = ex.Response as HttpWebResponse;
|
|
|
+ // ET.Log.Debug(ex.Response.ToString());
|
|
|
+ // }
|
|
|
|
|
|
}
|
|
|
-
|
|
|
//批量删除玩家相册
|
|
|
public static async ETTask<bool> ReqRemovedPhoto(List<long> pictureIds, int sourceType)
|
|
|
{
|