diff --git a/Server/Controller/Message/C2R_PingHandler.cs b/Server/Controller/Message/C2R_PingHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..7b702bf4e76e8a1708058e9addd20f2ef05b5db9 --- /dev/null +++ b/Server/Controller/Message/C2R_PingHandler.cs @@ -0,0 +1,15 @@ +using System; +using Model; + +namespace Controller +{ + [MessageHandler(AppType.Realm)] + public class C2R_PingHandler : AMRpcHandler + { + protected override void Run(Session session, C2R_Ping message, Action reply) + { + R2C_Ping r2CPing = new R2C_Ping(); + reply(r2CPing); + } + } +} \ No newline at end of file diff --git a/Server/Controller/Server.Controller.csproj b/Server/Controller/Server.Controller.csproj index 17bdc0948bfa3c8fd9589c1b4de21ad443a93936..f0ef4595fdc07023b6aae99ec2a44bc2667a089f 100644 --- a/Server/Controller/Server.Controller.csproj +++ b/Server/Controller/Server.Controller.csproj @@ -35,6 +35,7 @@ + diff --git a/Unity/Assets/Scripts/Component/BenchmakComponent.cs b/Unity/Assets/Scripts/Component/BenchmakComponent.cs index a4532130f0cee7e0bc9c0be53418b7bb883c5198..84515feb6d27c52b6e0997dcddee9b1ec73a4bc4 100644 --- a/Unity/Assets/Scripts/Component/BenchmakComponent.cs +++ b/Unity/Assets/Scripts/Component/BenchmakComponent.cs @@ -17,12 +17,15 @@ namespace Model { private int k; - public void Awake(string address) + private long time1 = TimeHelper.ClientNowTicks(); + + public async void Awake(string address) { NetOuterComponent networkComponent = Game.Scene.GetComponent(); - for (int i = 0; i < 400; i++) + for (int i = 0; i < 100; i++) { + await Game.Scene.GetComponent().WaitAsync(10); TestAsync(networkComponent, address, i); } } @@ -32,22 +35,20 @@ namespace Model using (Session session = networkComponent.Create(address)) { int i = 0; - while (i < 10000) + while (i < 10000000) { ++i; try { - R2C_Login s2CLogin = await session.Call(new C2R_Login { Account = "abcdef", Password = "111111" }); - - using (Session gateSession = networkComponent.Create(s2CLogin.Address)) - { - await gateSession.Call(new C2G_LoginGate(s2CLogin.Key)); - } + await session.Call(new C2R_Ping()); ++this.k; - if (this.k % 1000 == 0) + if (this.k % 100000 == 0) { - Log.Info($"{j} Benchmark k: {k}"); + long time2 = TimeHelper.ClientNowTicks(); + long time = time2 - this.time1; + this.time1 = time2; + Log.Info($"{j} Benchmark k: {k} 每10W次耗时: {time}"); } } catch (RpcException e) diff --git a/Unity/Assets/Scripts/Entity/Message/Message.cs b/Unity/Assets/Scripts/Entity/Message/Message.cs index a0080cd38ac7e6f49df86c446afd0dd0e65c8ae2..a665439f1e549aff32b3b904cb189e625ffcd6a9 100644 --- a/Unity/Assets/Scripts/Entity/Message/Message.cs +++ b/Unity/Assets/Scripts/Entity/Message/Message.cs @@ -111,4 +111,16 @@ namespace Model public class A2M_Reload : AResponse { } + + [Message(14)] + [BsonIgnoreExtraElements] + public class C2R_Ping : ARequest + { + } + + [Message(15)] + [BsonIgnoreExtraElements] + public class R2C_Ping : AResponse + { + } }