HttpGetVersionHandler.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections.Generic;
  2. using System.Net;
  3. namespace ET.Server
  4. {
  5. /// <summary>
  6. /// 获取版本号,用于强更
  7. /// </summary>
  8. [HttpHandler(SceneType.RouterManager, "/get_version")]
  9. public class HttpGetVersionHandler : IHttpHandler
  10. {
  11. public async ETTask Handle(Entity domain, HttpListenerContext context)
  12. {
  13. VersionInfo info = null;
  14. // 查询配置的版本号
  15. List<VersionInfo> list = await DBManagerComponent.Instance.GetZoneDB(1).Query<VersionInfo>(d => d.Version > 0);
  16. if (list is { Count: > 0 })
  17. {
  18. info = list[0];
  19. }
  20. else
  21. {
  22. info = new VersionInfo();
  23. info.Id = IdGenerater.Instance.GenerateId();
  24. info.Version = 100;
  25. info.Url = "https://d.apkpure.com/b/APK/com.tencent.tmgp.sgame?version=latest";
  26. await DBManagerComponent.Instance.GetZoneDB(1).Save<VersionInfo>(info);
  27. }
  28. HttpGetVersionResponse res = new HttpGetVersionResponse();
  29. res.Version = info.Version;
  30. res.Url = info.Url;
  31. HttpHelper.Response(context, res);
  32. await ETTask.CompletedTask;
  33. }
  34. }
  35. }