using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Reflection;
using ETModel.com.commsdk.unity3d;
using ETModel;
namespace ETHotfix
{
namespace com.commsdk.unity3d
{
///
///公用的原生sdk
///
public class CommSDKComponent : MonoBehaviour
{
private int WeReqID;
private CommSDKImpl commSdkUtils;
public EventWechatHandler responseHandler;
public void Init()
{
Debug.Log("GameObject.name = " + gameObject.name);
commSdkUtils = new AndroidImpl(gameObject.name, "_Callback");
}
///
/// callback the specified data.
///
///
/// Data.
///
private void _Callback(string data)
{
if (data == null)
{
Debug.Log("OnWechatLogin DataIsNull" + data + "DataIsNull Data");
return;
}
Hashtable res = (Hashtable)MiniJSON.jsonDecode(data);
if (res == null || res.Count <= 0)
{
Debug.Log("OnWechatLogin ResIsNull" + data + "ResIsNull Data");
return;
}
int status = Convert.ToInt32(res["status"]);
int reqID = Convert.ToInt32(res["reqID"]);
int action = Convert.ToInt32(res["action"]);
Hashtable resp = null;
switch ((RespState)status)
{
case RespState.Success:
case RespState.Fail:
resp = (Hashtable)res["res"];
break;
case RespState.Cancel:
break;
}
if (resp == null)
{
Debug.Log("OnWechatLogin RespIsNull" + data + "RespIsNull");
}
if (null != responseHandler)
{
responseHandler(reqID, (ActionType)action, (RespState)status, resp);
}
}
public int Authorize(int type)
{
WeReqID++;
commSdkUtils.Authorize(type, WeReqID);
return WeReqID;
}
///
/// Event result listener.
///
public delegate void EventWechatHandler(int reqID, ActionType type, RespState state, Hashtable data);
}
}
}