| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /*
- * File Name: AmlogicResolverJson
- * Author: Guan B
- * Version: 1.0.0
- * Data: 2022.04.08
- * Des: 接收解析Android端的数据
- * Other: Zeewain
- */
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Security.Cryptography;
- using LitJson;
- using UnityEngine;
- [Serializable]
- public class Body
- {
- /// <summary>
- ///
- /// </summary>
- public string gameId;
- /// <summary>
- ///
- /// </summary>
- public string token;
- /// <summary>
- ///
- /// </summary>
- public string skuId;
- /// <summary>
- ///
- /// </summary>
- public string baseUri;
- public string ak;
- public string sk;
- public string hostPkg;
- public string authUri;
- public int openCameraStatus;
- }
- [Serializable]
- public class Root
- {
- /// <summary>
- ///
- /// </summary>
- public int cmd;
- /// <summary>
- ///
- /// </summary>
- public int seq;
- /// <summary>
- ///
- /// </summary>
- public Body body;
- /// <summary>
- ///
- /// </summary>
- public int state;
- }
- public class AmlogicResolverJson : MonoBehaviour
- {
- public static AmlogicResolverJson single;
- private void Awake()
- {
- single = this;
- }
- public void read_json(string str)
- {
- Root root_json = ReadJosn.LoadJson<Root>(str);
- if (root_json.cmd == 203)
- {
-
- if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
- {
- if (root_json.body.openCameraStatus == 1)
- {
- //Log.Debug("接收到203协议===========成功开启相机 ");
- //成功开启相机
- ZwnAmlogicHelperData.isOpenCamera = true;
- ZwnAmlogicHelperData.isCanOpenCamera = false;
- }
- else if (root_json.body.openCameraStatus == 0)
- {
- //已经可以开启相机
- ZwnAmlogicHelperData.isCanOpenCamera = true;
- //Log.Debug("接收到203协议===========已经可以开启相机 ");
- }
- else
- {
- //打开相机失败
- //Log.Debug("接收到203协议===========打开相机失败 ");
- ZwnAmlogicHelperData.isOpenCamera = false;
- }
- }
- }
- else if (root_json.cmd == 104)
- {
- print("接受到104消息");
- print("传过来的ak:______" + root_json.body.ak);
- print("传过来的sk:______" + root_json.body.sk);
- print("传过来的hostPkg:______" + root_json.body.hostPkg);
- print("传过来的authUri:______" + root_json.body.authUri);
- print("传过来的token:______" + root_json.body.token);
- WebRequestData.License_url = root_json.body.authUri + "/api/auth/client/get-license";
- WebRequestBackgroundPrefix.WebRequestPrefixData = root_json.body.authUri;
- if (str.Contains("token"))
- {
- WebRequestBackgroundData.tokenData = root_json.body.token;
- }
- else
- {
- WebRequestBackgroundData.tokenData = "";
- }
- print("resolverjson tokenData " + WebRequestBackgroundData.tokenData);
- print("resolverjson WebRequestPrefixData " + WebRequestBackgroundPrefix.WebRequestPrefixData);
- }
- }
- bool send_success = false;
- public bool Send_Success
- {
- get { return send_success; }
- set { send_success = value; }
- }
- public void send_http()
- {
- if (Application.platform == RuntimePlatform.WindowsEditor
- || Application.platform == RuntimePlatform.WindowsPlayer)
- {
- send_success = true;
- //httpreturndatatest_cur.send_http();
- //print("send_success: " + send_success);
- }
- if (Application.platform == RuntimePlatform.WindowsPlayer)
- {
- send_success = true;
- //print("send_success: " + send_success);
- }
- if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
- {
- send_success = true;
- //httpreturndatatest_cur.send_http();
- //print("send_success: " + send_success);
- }
- }
- bool send_inquiry_success = false;
- public bool Send_Inquiry_Success
- {
- get { return send_inquiry_success; }
- set { send_inquiry_success = value; }
- }
- public void send_inquiry_http()
- {
- if (Application.platform == RuntimePlatform.WindowsEditor)
- {
- send_inquiry_success = true;
- //httpreturndatatest_cur.balance_inquiry();
- //print("send_inquiry_success : " + send_inquiry_success);
- }
- if (Application.platform == RuntimePlatform.WindowsPlayer)
- {
- PlayerPrefs.SetInt("balance", -1);
- send_inquiry_success = true;
- //print("send_inquiry_success : " + send_inquiry_success);
- }
- if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟
- {
- send_inquiry_success = true;
- //httpreturndatatest_cur.balance_inquiry();
- //print("send_inquiry_success : " + send_inquiry_success);
- }
- }
- }
|