Просмотр исходного кода

把Sender的await暴露出来,可以让rpc过程中先发送sender消息成功,保证顺序

tanghai 1 год назад
Родитель
Сommit
d8323b0199

+ 2 - 2
Unity/Packages/cn.etetet.actorlocation/Scripts/Hotfix/Server/MessageLocationSenderComponentSystem.cs

@@ -91,9 +91,9 @@ namespace ET.Server
         
         // 发给不会改变位置的actorlocation用这个,这种actor消息不会阻塞发送队列,性能更高
         // 发送过去找不到actor不会重试,用此方法,你得保证actor提前注册好了location
-        public static void Send(this MessageLocationSenderOneType self, long entityId, IMessage message)
+        public static async ETTask Send(this MessageLocationSenderOneType self, long entityId, IMessage message)
         {
-            self.SendInner(entityId, message).NoContext();
+            await self.SendInner(entityId, message);
         }
         
         private static async ETTask SendInner(this MessageLocationSenderOneType self, long entityId, IMessage message)

+ 5 - 5
Unity/Packages/cn.etetet.statesync/Scripts/Hotfix/Server/Map/MapMessageHelper.cs

@@ -11,14 +11,14 @@ namespace ET.Server
         {
             M2C_CreateUnits createUnits = M2C_CreateUnits.Create();
             createUnits.Units.Add(UnitHelper.CreateUnitInfo(sendUnit));
-            MapMessageHelper.SendToClient(unit, createUnits);
+            MapMessageHelper.SendToClient(unit, createUnits).NoContext();
         }
         
         public static void NoticeUnitRemove(Unit unit, Unit sendUnit)
         {
             M2C_RemoveUnits removeUnits = M2C_RemoveUnits.Create();
             removeUnits.Units.Add(sendUnit.Id);
-            MapMessageHelper.SendToClient(unit, removeUnits);
+            MapMessageHelper.SendToClient(unit, removeUnits).NoContext();
         }
         
         public static void Broadcast(Unit unit, IMessage message)
@@ -29,13 +29,13 @@ namespace ET.Server
             MessageLocationSenderOneType oneTypeMessageLocationType = unit.Root().GetComponent<MessageLocationSenderComponent>().Get(LocationType.GateSession);
             foreach (AOIEntity u in dict.Values)
             {
-                oneTypeMessageLocationType.Send(u.Unit.Id, message);
+                oneTypeMessageLocationType.Send(u.Unit.Id, message).NoContext();
             }
         }
         
-        public static void SendToClient(Unit unit, IMessage message)
+        public static async ETTask SendToClient(Unit unit, IMessage message)
         {
-            unit.Root().GetComponent<MessageLocationSenderComponent>().Get(LocationType.GateSession).Send(unit.Id, message);
+            await unit.Root().GetComponent<MessageLocationSenderComponent>().Get(LocationType.GateSession).Send(unit.Id, message);
         }
         
         /// <summary>

+ 2 - 2
Unity/Packages/cn.etetet.statesync/Scripts/Hotfix/Server/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -30,12 +30,12 @@ namespace ET.Server
             M2C_StartSceneChange m2CStartSceneChange = M2C_StartSceneChange.Create();
             m2CStartSceneChange.SceneInstanceId = scene.InstanceId;
             m2CStartSceneChange.SceneName = scene.Name;
-            MapMessageHelper.SendToClient(unit, m2CStartSceneChange);
+            await MapMessageHelper.SendToClient(unit, m2CStartSceneChange);
 
             // 通知客户端创建My Unit
             M2C_CreateMyUnit m2CCreateUnits = M2C_CreateMyUnit.Create();
             m2CCreateUnits.Unit = UnitHelper.CreateUnitInfo(unit);
-            MapMessageHelper.SendToClient(unit, m2CCreateUnits);
+            await MapMessageHelper.SendToClient(unit, m2CCreateUnits);
 
             // 加入aoi
             unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);

+ 0 - 1
Unity/Packages/manifest.json

@@ -11,7 +11,6 @@
     "com.unity.textmeshpro": "3.0.6",
     "com.unity.timeline": "1.7.6",
     "com.unity.ugui": "1.0.0",
-    "com.unity.upm.develop": "0.5.1",
     "com.unity.modules.ai": "1.0.0",
     "com.unity.modules.androidjni": "1.0.0",
     "com.unity.modules.animation": "1.0.0",

+ 0 - 27
Unity/Packages/packages-lock.json

@@ -231,15 +231,6 @@
       },
       "url": "https://packages.unity.com"
     },
-    "com.unity.asset-store-validation": {
-      "version": "0.1.3",
-      "depth": 1,
-      "source": "registry",
-      "dependencies": {
-        "com.unity.nuget.newtonsoft-json": "2.0.2"
-      },
-      "url": "https://packages.unity.com"
-    },
     "com.unity.burst": {
       "version": "1.8.11",
       "depth": 1,
@@ -288,13 +279,6 @@
       "dependencies": {},
       "url": "https://packages.unity.com"
     },
-    "com.unity.nuget.newtonsoft-json": {
-      "version": "3.2.1",
-      "depth": 1,
-      "source": "registry",
-      "dependencies": {},
-      "url": "https://packages.unity.com"
-    },
     "com.unity.render-pipelines.core": {
       "version": "14.0.9",
       "depth": 1,
@@ -390,17 +374,6 @@
         "com.unity.modules.imgui": "1.0.0"
       }
     },
-    "com.unity.upm.develop": {
-      "version": "0.5.1",
-      "depth": 0,
-      "source": "registry",
-      "dependencies": {
-        "com.unity.test-framework": "1.1.20",
-        "com.unity.asset-store-validation": "0.1.3",
-        "com.unity.nuget.newtonsoft-json": "2.0.2"
-      },
-      "url": "https://packages.unity.com"
-    },
     "com.unity.modules.ai": {
       "version": "1.0.0",
       "depth": 0,