/*
* 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
{
///
///
///
public string gameId;
///
///
///
public string token;
///
///
///
public string skuId;
///
///
///
public string baseUri;
public string ak;
public string sk;
public string hostPkg;
public string authUri;
public int openCameraStatus;
}
[Serializable]
public class Root
{
///
///
///
public int cmd;
///
///
///
public int seq;
///
///
///
public Body body;
///
///
///
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(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);
}
}
}