AmlogicResolverJson.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * File Name: AmlogicResolverJson
  3. * Author: Guan B
  4. * Version: 1.0.0
  5. * Data: 2022.04.08
  6. * Des: 接收解析Android端的数据
  7. * Other: Zeewain
  8. */
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Security.Cryptography;
  13. using LitJson;
  14. using UnityEngine;
  15. [Serializable]
  16. public class Body
  17. {
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. public string gameId;
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. public string token;
  26. /// <summary>
  27. ///
  28. /// </summary>
  29. public string skuId;
  30. /// <summary>
  31. ///
  32. /// </summary>
  33. public string baseUri;
  34. public string ak;
  35. public string sk;
  36. public string hostPkg;
  37. public string authUri;
  38. public int openCameraStatus;
  39. }
  40. [Serializable]
  41. public class Root
  42. {
  43. /// <summary>
  44. ///
  45. /// </summary>
  46. public int cmd;
  47. /// <summary>
  48. ///
  49. /// </summary>
  50. public int seq;
  51. /// <summary>
  52. ///
  53. /// </summary>
  54. public Body body;
  55. /// <summary>
  56. ///
  57. /// </summary>
  58. public int state;
  59. }
  60. public class AmlogicResolverJson : MonoBehaviour
  61. {
  62. public static AmlogicResolverJson single;
  63. private void Awake()
  64. {
  65. single = this;
  66. }
  67. public void read_json(string str)
  68. {
  69. Root root_json = ReadJosn.LoadJson<Root>(str);
  70. if (root_json.cmd == 203)
  71. {
  72. if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
  73. {
  74. if (root_json.body.openCameraStatus == 1)
  75. {
  76. //Log.Debug("接收到203协议===========成功开启相机 ");
  77. //成功开启相机
  78. ZwnAmlogicHelperData.isOpenCamera = true;
  79. ZwnAmlogicHelperData.isCanOpenCamera = false;
  80. }
  81. else if (root_json.body.openCameraStatus == 0)
  82. {
  83. //已经可以开启相机
  84. ZwnAmlogicHelperData.isCanOpenCamera = true;
  85. //Log.Debug("接收到203协议===========已经可以开启相机 ");
  86. }
  87. else
  88. {
  89. //打开相机失败
  90. //Log.Debug("接收到203协议===========打开相机失败 ");
  91. ZwnAmlogicHelperData.isOpenCamera = false;
  92. }
  93. }
  94. }
  95. else if (root_json.cmd == 104)
  96. {
  97. print("接受到104消息");
  98. print("传过来的ak:______" + root_json.body.ak);
  99. print("传过来的sk:______" + root_json.body.sk);
  100. print("传过来的hostPkg:______" + root_json.body.hostPkg);
  101. print("传过来的authUri:______" + root_json.body.authUri);
  102. print("传过来的token:______" + root_json.body.token);
  103. WebRequestData.License_url = root_json.body.authUri + "/api/auth/client/get-license";
  104. WebRequestBackgroundPrefix.WebRequestPrefixData = root_json.body.authUri;
  105. if (str.Contains("token"))
  106. {
  107. WebRequestBackgroundData.tokenData = root_json.body.token;
  108. }
  109. else
  110. {
  111. WebRequestBackgroundData.tokenData = "";
  112. }
  113. print("resolverjson tokenData " + WebRequestBackgroundData.tokenData);
  114. print("resolverjson WebRequestPrefixData " + WebRequestBackgroundPrefix.WebRequestPrefixData);
  115. }
  116. }
  117. bool send_success = false;
  118. public bool Send_Success
  119. {
  120. get { return send_success; }
  121. set { send_success = value; }
  122. }
  123. public void send_http()
  124. {
  125. if (Application.platform == RuntimePlatform.WindowsEditor
  126. || Application.platform == RuntimePlatform.WindowsPlayer)
  127. {
  128. send_success = true;
  129. //httpreturndatatest_cur.send_http();
  130. //print("send_success: " + send_success);
  131. }
  132. if (Application.platform == RuntimePlatform.WindowsPlayer)
  133. {
  134. send_success = true;
  135. //print("send_success: " + send_success);
  136. }
  137. if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
  138. {
  139. send_success = true;
  140. //httpreturndatatest_cur.send_http();
  141. //print("send_success: " + send_success);
  142. }
  143. }
  144. bool send_inquiry_success = false;
  145. public bool Send_Inquiry_Success
  146. {
  147. get { return send_inquiry_success; }
  148. set { send_inquiry_success = value; }
  149. }
  150. public void send_inquiry_http()
  151. {
  152. if (Application.platform == RuntimePlatform.WindowsEditor)
  153. {
  154. send_inquiry_success = true;
  155. //httpreturndatatest_cur.balance_inquiry();
  156. //print("send_inquiry_success : " + send_inquiry_success);
  157. }
  158. if (Application.platform == RuntimePlatform.WindowsPlayer)
  159. {
  160. PlayerPrefs.SetInt("balance", -1);
  161. send_inquiry_success = true;
  162. //print("send_inquiry_success : " + send_inquiry_success);
  163. }
  164. if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
  165. {
  166. send_inquiry_success = true;
  167. //httpreturndatatest_cur.balance_inquiry();
  168. //print("send_inquiry_success : " + send_inquiry_success);
  169. }
  170. }
  171. }