|
@@ -17,6 +17,8 @@ public class HttpHelper : MonoBehaviour
|
|
|
{
|
|
|
public Action OnSWYJRefresh;
|
|
|
|
|
|
+ public static bool useAes = false;
|
|
|
+
|
|
|
public static HttpHelper _Instance;
|
|
|
|
|
|
public static Dictionary<string, DevicesId_Data> _devicesIdDatas = new Dictionary<string, DevicesId_Data>();
|
|
@@ -26,7 +28,8 @@ public class HttpHelper : MonoBehaviour
|
|
|
private async void Awake()
|
|
|
{
|
|
|
_Instance = this;
|
|
|
- await GetSensorList();
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if (GlobalData.pageIndex == PageIndex.Page1 || GlobalData.pageIndex == PageIndex.Page2 ||
|
|
|
GlobalData.pageIndex == PageIndex.Page3)
|
|
@@ -54,6 +57,7 @@ public class HttpHelper : MonoBehaviour
|
|
|
if (GlobalData.pageIndex == PageIndex.Page1)
|
|
|
{
|
|
|
Debug.Log("HttpInitGCJKData");
|
|
|
+ GetSensorList();
|
|
|
//可以并行,无需等待
|
|
|
InitGCJKData();
|
|
|
}
|
|
@@ -127,7 +131,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -175,7 +185,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -226,7 +242,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -278,7 +300,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -374,7 +402,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -433,8 +467,15 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Debug.Log("补元监控数据返回:" + requestData.downloadHandler.text);
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ Debug.Log("补元监控数据返回:"+requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
+
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -514,8 +555,16 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Debug.Log("套口监控数据返回:" + requestData.downloadHandler.text);
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+
|
|
|
+ Debug.Log("套口监控数据返回:"+requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
+
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -569,32 +618,38 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public async Task<string> GetObsUrl(string deviceId, string channelId)
|
|
|
- {
|
|
|
- string result = "";
|
|
|
- string cmdUrl = ServerAddress.API_PlayStart;
|
|
|
- cmdUrl += $"/{deviceId}/{channelId}";
|
|
|
- Debug.Log($"send:{cmdUrl}");
|
|
|
- UnityWebRequest requestData = UnityWebRequest.Get(cmdUrl);
|
|
|
- await requestData.SendWebRequest();
|
|
|
- if (requestData.result != UnityWebRequest.Result.Success)
|
|
|
- {
|
|
|
- Debug.LogWarning($"获取监控播放地址不成功,原因:返request不成功:" + requestData.downloadHandler.text);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.Log(requestData.downloadHandler.text);
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+
|
|
|
+ public async Task<string> GetObsUrl(string deviceId,string channelId)
|
|
|
+ {
|
|
|
+ string result = "";
|
|
|
+ string cmdUrl = ServerAddress.API_PlayStart;
|
|
|
+ cmdUrl += $"/{deviceId}/{channelId}";
|
|
|
+ Debug.Log($"send:{cmdUrl}");
|
|
|
+ UnityWebRequest requestData = UnityWebRequest.Get(cmdUrl);
|
|
|
+ await requestData.SendWebRequest();
|
|
|
+ if (requestData.result != UnityWebRequest.Result.Success)
|
|
|
+ {
|
|
|
+ Debug.LogWarning($"获取监控播放地址不成功,原因:返request不成功:" + requestData.downloadHandler.text);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.Log(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
|
- ObsPlayUrlData urlData = JsonConvert.DeserializeObject<ObsPlayUrlData>(dataToken.ToString());
|
|
|
- result = urlData.hls;
|
|
|
- Debug.Log("获取到监控播放路径:" + result);
|
|
|
- }
|
|
|
-
|
|
|
- requestData.Dispose();
|
|
|
- return result;
|
|
|
- }
|
|
|
+ ObsPlayUrlData urlData = JsonConvert.DeserializeObject<ObsPlayUrlData>(dataToken.ToString());
|
|
|
+ result = urlData.hls;
|
|
|
+ Debug.Log("获取到监控播放路径:"+result);
|
|
|
+ }
|
|
|
+ requestData.Dispose();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
public async Task InitYZTData3()
|
|
|
{
|
|
@@ -611,7 +666,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -659,7 +720,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// ȡdata ֶε ֵ
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -707,7 +774,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -792,7 +865,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -828,6 +907,9 @@ public class HttpHelper : MonoBehaviour
|
|
|
public async Task InitSWYJData()
|
|
|
{
|
|
|
InitSWYJData0();
|
|
|
+ if (_devicesIdDatas.Count < 1) {
|
|
|
+ await GetSensorList();
|
|
|
+ }
|
|
|
await InitSWYJData1();
|
|
|
await InitSWYJData2();
|
|
|
OnSWYJRefresh?.Invoke();
|
|
@@ -980,7 +1062,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -1033,7 +1121,13 @@ public class HttpHelper : MonoBehaviour
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
|
|
|
+ string postResult = requestData.downloadHandler.text;
|
|
|
+ if (useAes)
|
|
|
+ {
|
|
|
+ postResult = AESCrypto.Decrypt(postResult);
|
|
|
+
|
|
|
+ }
|
|
|
+ JObject jsonObject = JObject.Parse(postResult);
|
|
|
|
|
|
// 提取data字段的值
|
|
|
JToken dataToken = jsonObject["data"];
|
|
@@ -1503,6 +1597,7 @@ public class HttpHelper : MonoBehaviour
|
|
|
{
|
|
|
bool successInternet = true;
|
|
|
UnityWebRequest www = UnityWebRequest.Get(ServerAddress.API_GetAllSensorList);
|
|
|
+ www.timeout = timeOut;
|
|
|
await www.SendWebRequest();
|
|
|
try
|
|
|
{
|
|
@@ -1535,7 +1630,7 @@ public class HttpHelper : MonoBehaviour
|
|
|
{
|
|
|
WWW localWWW = new WWW(Application.streamingAssetsPath + "/SensorList.json");
|
|
|
await new UnityAsync.WaitUntil(() => { return localWWW.isDone; });
|
|
|
- SensorListResult tempData = JsonUtility.FromJson<SensorListResult>(www.downloadHandler.text);
|
|
|
+ SensorListResult tempData = JsonUtility.FromJson<SensorListResult>(localWWW.text);
|
|
|
_devicesIdDatas = new Dictionary<string, DevicesId_Data>();
|
|
|
for (int i = 0; i < tempData.rows.Count; i++)
|
|
|
{
|