HttpStaticMessage.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Engine.Http;
  5. using System;
  6. /// <summary>消息工具类</summary>
  7. public class HttpStaticMessage
  8. {
  9. //httpRequest.Code 是用来返回请求的时候区别是哪个消息返回的数据
  10. /// <summary>发送Http请求获取玩家信息</summary>
  11. public static void SendHttpLogin(string user_name, string pwd, string code, Action<HttpResponse> callback)
  12. {
  13. HttpRequest req = HttpRequest.OnCreateRequest();
  14. req.URL = GameEnum.ServerHttpURL + "login/";
  15. req.Code = MsgConst.HTTP_MSG_LOGIN;
  16. req.AddParam("user_name", user_name);
  17. req.AddParam("password", pwd);
  18. req.AddParam("code", code);//验证码
  19. req.AddParam("deviceId", CStaticMethod.SerialId());
  20. req.AddParam("deviceType", CStaticMethod.DeviceType());
  21. HttpManager.GetInstance().SendMessage(req, callback);
  22. }
  23. public static void HttpVisitorLogin(string vistor_name, Action<HttpResponse> callback)
  24. {
  25. HttpRequest req = HttpRequest.OnCreateRequest();
  26. req.URL = GameEnum.ServerHttpURL + "login/";
  27. req.Code = MsgConst.HTTP_MSG_AUTO_LOGIN;
  28. req.AddParam("user_name", CStaticMethod.SerialId());
  29. req.AddParam("password", "");
  30. req.AddParam("deviceId", CStaticMethod.SerialId());
  31. req.AddParam("deviceType", CStaticMethod.DeviceType());
  32. //httpRequest.AddParam("vistor_name", vistor_name);
  33. HttpManager.GetInstance().SendMessage(req, callback);
  34. }
  35. /// <summary>获取题库</summary>
  36. public static void SendHttpQuestion(int user_id, short course_id)
  37. {
  38. HttpRequest req = HttpRequest.OnCreateRequest();
  39. req.URL = GameEnum.ServerHttpURL + "enter/";
  40. req.Code = MsgConst.HTTP_MSG_GET_QUESTION;
  41. req.AddParam("user_id", user_id.ToString());
  42. req.AddParam("course_id", course_id.ToString());
  43. HttpManager.GetInstance().SendMessage(req);
  44. }
  45. public static void AutoSendHttpVerson(string ver, bool isDebug = false)
  46. {
  47. HttpRequest httpRequest = HttpRequest.OnCreateRequest();
  48. httpRequest.URL = GameEnum.ServerHttpURL + "checkVer/";
  49. httpRequest.Code = MsgConst.HTTP_MSG_VERSION;
  50. httpRequest.AddParam("ver", ver);
  51. httpRequest.AddParam("debug", (isDebug ? 1 : 0).ToString());
  52. HttpManager.GetInstance().SendMessage(httpRequest);
  53. }
  54. public static string GetUniqueId()
  55. {
  56. return SystemInfo.deviceUniqueIdentifier;//设备唯一标识符 MD5加密的
  57. }
  58. }