您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 

89 行
2.8 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Text;
  7. using System.Reflection;
  8. using ETModel.com.commsdk.unity3d;
  9. using ETModel;
  10. namespace ETHotfix
  11. {
  12. namespace com.commsdk.unity3d
  13. {
  14. /// <summary>
  15. ///公用的原生sdk
  16. /// </summary>
  17. public class CommSDKComponent : MonoBehaviour
  18. {
  19. private int WeReqID;
  20. private CommSDKImpl commSdkUtils;
  21. public EventWechatHandler responseHandler;
  22. public void Init()
  23. {
  24. Debug.Log("GameObject.name = " + gameObject.name);
  25. commSdkUtils = new AndroidImpl(gameObject.name, "_Callback");
  26. }
  27. /// <summary>
  28. /// callback the specified data.
  29. /// </summary>
  30. /// <param name='data'>
  31. /// Data.
  32. /// </param>
  33. private void _Callback(string data)
  34. {
  35. if (data == null)
  36. {
  37. Debug.Log("OnWechatLogin DataIsNull" + data + "DataIsNull Data");
  38. return;
  39. }
  40. Hashtable res = (Hashtable)MiniJSON.jsonDecode(data);
  41. if (res == null || res.Count <= 0)
  42. {
  43. Debug.Log("OnWechatLogin ResIsNull" + data + "ResIsNull Data");
  44. return;
  45. }
  46. int status = Convert.ToInt32(res["status"]);
  47. int reqID = Convert.ToInt32(res["reqID"]);
  48. int action = Convert.ToInt32(res["action"]);
  49. Hashtable resp = null;
  50. switch ((RespState)status)
  51. {
  52. case RespState.Success:
  53. case RespState.Fail:
  54. resp = (Hashtable)res["res"];
  55. break;
  56. case RespState.Cancel:
  57. break;
  58. }
  59. if (resp == null)
  60. {
  61. Debug.Log("OnWechatLogin RespIsNull" + data + "RespIsNull");
  62. }
  63. if (null != responseHandler)
  64. {
  65. responseHandler(reqID, (ActionType)action, (RespState)status, resp);
  66. }
  67. }
  68. public int Authorize(int type)
  69. {
  70. WeReqID++;
  71. commSdkUtils.Authorize(type, WeReqID);
  72. return WeReqID;
  73. }
  74. /// <summary>
  75. /// Event result listener.
  76. /// </summary>
  77. public delegate void EventWechatHandler(int reqID, ActionType type, RespState state, Hashtable data);
  78. }
  79. }
  80. }