WebRequestBackgroundData.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WebRequestBackgroundData
  5. {
  6. //体验流水数据
  7. public static string flowData = WebRequestBackgroundPrefix.WebRequestPrefixData + "/api/product-data-access/evaluate-flow-data/add";
  8. //软件编码
  9. public static string softwareCode = "ZWN_SW_UNITY_LLK_001";
  10. //token
  11. public static string tokenData = "";
  12. //public static string tokenData = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ6ZWV3YWluIiwidXNlcklkIjoyNzUwMDUyNDUzMDA5ODE4MywidXNlckNvZGUiOiJ6d25fMjc1MDA1MjQ1MzAwOTgxODQiLCJleHBpcmVUaW1lIjoxNjQzODYwNTYzNTYwLCJleHAiOjE2NDM4NjA1NjN9.OBj7a5AxqtGThiaKOzez78pRsgUPeObdZMt1ESwkr4c";
  13. //Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ6ZWV3YWluIiwidXNlcklkIjoyNzUwMDUyNDUzMDA5ODE4MywidXNlckNvZGUiOiJ6d25fMjc1MDA1MjQ1MzAwOTgxODQiLCJleHBpcmVUaW1lIjoxNjQzODYwNTYzNTYwLCJleHAiOjE2NDM4NjA1NjN9.OBj7a5AxqtGThiaKOzez78pRsgUPeObdZMt1ESwkr4c
  14. // todo: For Project LinkGame 需要移出去
  15. /// <summary>
  16. /// 发送服务器数据和接收游戏总时长
  17. /// </summary>
  18. /// <param name="correctRate">准确率</param>
  19. /// <param name="experienceTime">体验时长,单位(秒)</param>
  20. /// <param name="focusResult">专注评价</param>
  21. /// <param name="gameLevel">课件关卡</param>
  22. /// <param name="reactionResult">反应评价</param>
  23. /// <param name="sportResult">运动评价</param>
  24. /// <returns></returns>
  25. public static int GetFlowData(string correctRate, int experienceTime, string focusResult, int gameLevel,string reactionResult, string sportResult)
  26. {
  27. string stateUrl = flowData;
  28. string softwareCode = WebRequestBackgroundData.softwareCode;
  29. string heraddata = tokenData;
  30. int gameTotalduration = 0;
  31. string requestJson = string.Format(@"{{""correctRate"":""{0}"",""experienceTime"":{1},""focusResult"":""{2}"",""gameLevel"":{3},""reactionResult"":""{4}"",""softwareCode"":""{5}"",""sportResult"":""{6}""}}",
  32. correctRate, experienceTime, focusResult, gameLevel, reactionResult, softwareCode, sportResult);
  33. if (string.IsNullOrEmpty(heraddata)) { }
  34. else
  35. {
  36. HttpWebRequsetManger.SendHttpData(heraddata, stateUrl, requestJson, (string data) =>
  37. {
  38. JsonBackgroundFlowData jsonEmpowerData = ReadJosn.LoadJson<JsonBackgroundFlowData>(data);
  39. if (jsonEmpowerData.code == 0)
  40. {
  41. gameTotalduration = jsonEmpowerData.data.evaluateTime / 60;
  42. }
  43. else
  44. {
  45. Debug.Log("code不为0 message" + jsonEmpowerData.message);
  46. }
  47. });
  48. }
  49. return gameTotalduration;
  50. }
  51. }