Parcourir la source

【功能】增加服务器版本控制,整包强更提醒

johnclot69 il y a 1 an
Parent
commit
9f39b4c5af

+ 8 - 0
Config/Proto/OuterMessage_C_10001.proto

@@ -347,4 +347,12 @@ message HttpDouyinApiCallbackResponse
 {
 	int32 Error = 1;
 	string Message = 2;
+}
+
+message HttpGetVersionResponse
+{
+	int32 Error = 1;
+	string Message = 2;
+	int64 Version = 3;	// 版本号
+	string Url = 4;	// 新包地址
 }

+ 3 - 0
DotNet/Hotfix/Helper/SceneFactory.cs

@@ -15,6 +15,9 @@ namespace ET.Server
             switch (scene.SceneType)
             {
                 case SceneType.Router:
+                    // 云服务器中,一般来说router要单独部署,不过大家经常放在一起,那么下面要修改
+                    // startSceneConfig.OuterIPPort改成startSceneConfig.InnerIPOutPort
+                    // 然后云服务器防火墙把端口映射过来
                     scene.AddComponent<RouterComponent, IPEndPoint, string>(startSceneConfig.OuterIPPort,
                         startSceneConfig.StartProcessConfig.InnerIP
                     );

+ 40 - 0
DotNet/Hotfix/Scenes/Router/HttpGetVersionHandler.cs

@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+using System.Net;
+
+namespace ET.Server
+{
+    /// <summary>
+    /// 获取版本号,用于强更
+    /// </summary>
+    [HttpHandler(SceneType.RouterManager, "/get_version")]
+    public class HttpGetVersionHandler : IHttpHandler
+    {
+        public async ETTask Handle(Entity domain, HttpListenerContext context)
+        {
+            VersionInfo info = null;
+
+            // 查询配置的版本号
+            List<VersionInfo> list = await DBManagerComponent.Instance.GetZoneDB(1).Query<VersionInfo>(d => d.Version > 0);
+
+            if (list is { Count: > 0 })
+            {
+                info = list[0];
+            }
+            else
+            {
+                info = new VersionInfo();
+                info.Id = IdGenerater.Instance.GenerateId();
+                info.Version = 100;
+                info.Url = "https://d.apkpure.com/b/APK/com.tencent.tmgp.sgame?version=latest";
+
+                await DBManagerComponent.Instance.GetZoneDB(1).Save<VersionInfo>(info);
+            }
+
+            HttpGetVersionResponse res = new HttpGetVersionResponse();
+            res.Version = info.Version;
+            res.Url = info.Url;
+            HttpHelper.Response(context, res);
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 19 - 0
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -721,6 +721,24 @@ namespace ET
 
 	}
 
+	[Message(OuterMessage.HttpGetVersionResponse)]
+	[ProtoContract]
+	public partial class HttpGetVersionResponse: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int Error { get; set; }
+
+		[ProtoMember(2)]
+		public string Message { get; set; }
+
+		[ProtoMember(3)]
+		public long Version { get; set; }
+
+		[ProtoMember(4)]
+		public string Url { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -771,5 +789,6 @@ namespace ET
 		 public const ushort G2C_Benchmark = 10047;
 		 public const ushort R2C_Disconnect = 10048;
 		 public const ushort HttpDouyinApiCallbackResponse = 10049;
+		 public const ushort HttpGetVersionResponse = 10050;
 	}
 }

+ 14 - 0
DotNet/Model/Scenes/Realm/DBEntity/VersionInfo.cs

@@ -0,0 +1,14 @@
+namespace ET.Server
+{
+    /// <summary>
+    /// 版本号信息
+    /// </summary>
+    [ChildOf(typeof (Session))]
+    public class VersionInfo: Entity, IAwake
+    {
+        /** 版本号 **/
+        public long Version { get; set; }
+        /** 新包地址 **/
+        public string Url { get; set; }
+    }
+}

+ 19 - 0
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs

@@ -721,6 +721,24 @@ namespace ET
 
 	}
 
+	[Message(OuterMessage.HttpGetVersionResponse)]
+	[ProtoContract]
+	public partial class HttpGetVersionResponse: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int Error { get; set; }
+
+		[ProtoMember(2)]
+		public string Message { get; set; }
+
+		[ProtoMember(3)]
+		public long Version { get; set; }
+
+		[ProtoMember(4)]
+		public string Url { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -771,5 +789,6 @@ namespace ET
 		 public const ushort G2C_Benchmark = 10047;
 		 public const ushort R2C_Disconnect = 10048;
 		 public const ushort HttpDouyinApiCallbackResponse = 10049;
+		 public const ushort HttpGetVersionResponse = 10050;
 	}
 }

+ 0 - 11
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 26923f18a432ab740b53d6d218076c02
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: