Explorar o código

1.增加Benchmark AppType,方便做压力测试
2.ENet做客户端连接超过4000会有问题
3.ENet做客户端不同连接可能会使用同一端口

tanghai %!s(int64=9) %!d(string=hai) anos
pai
achega
cf96343394

+ 2 - 0
Config/StartConfig/Benchmark.txt

@@ -0,0 +1,2 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96832337674244"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832337674245"), "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832337674246"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96866810789911"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96866810789912"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" }

+ 17 - 0
Config/StartConfig/Benchmark127.0.0.1.txt

@@ -0,0 +1,17 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20001 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 2, "AppType" : "Realm", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20002 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10002 }], "AppId" : 3, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20003 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10003 }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20004 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10004 }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "127.0.0.1", "Port" : 20005 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "127.0.0.1", "Port" : 10005 }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 7, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 8, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 9, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 10, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 11, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 12, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 13, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 14, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 15, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 16, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96867298967576"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96867298967577"), "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 17, "AppType" : "Benchmark", "ServerIP" : "*" }

+ 10 - 5
Server/App/Program.cs

@@ -28,35 +28,40 @@ namespace App
 
 				Game.Scene.AddComponent<EventComponent>();
 				Game.Scene.AddComponent<TimerComponent>();
-
-				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
-				Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
+				
 				Game.Scene.AddComponent<MessageDispatherComponent, AppType>(startConfig.AppType);
 
 				// 根据不同的AppType添加不同的组件
 				OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();
+				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
+				ClientConfig clientConfig = startConfig.GetComponent<ClientConfig>();
 				switch (startConfig.AppType)
 				{
 					case AppType.Manager:
+						Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
 						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
 						Game.Scene.AddComponent<AppManagerComponent>();
 						break;
 					case AppType.Realm:
+						Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
 						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
 						break;
 					case AppType.Gate:
+						Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
 						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						break;
 					case AppType.AllServer:
+						Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
 						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
 						Game.Scene.AddComponent<AppManagerComponent>();
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						break;
-					case AppType.Robot:
-						Game.Scene.AddComponent<RobotComponent>();
+					case AppType.Benchmark:
+						Game.Scene.AddComponent<NetOuterComponent>();
+						Game.Scene.AddComponent<BenchmakComponent, string>(clientConfig.Address);
 						break;
 					default:
 						throw new Exception($"命令行参数没有设置正确的AppType: {startConfig.AppType}");

+ 6 - 0
Server/Model/Server.Model.csproj

@@ -41,6 +41,9 @@
     <Reference Include="System.Core" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="..\..\Unity\Assets\Scripts\Component\BenchmakComponent.cs">
+      <Link>Component\BenchmakComponent.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Component\ConfigComponent.cs">
       <Link>Component\ConfigComponent.cs</Link>
     </Compile>
@@ -143,6 +146,9 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Other\BsonClassMapRegister.cs">
       <Link>Other\BsonClassMapRegister.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Other\ClientConfig.cs">
+      <Link>Other\ClientConfig.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\EntityType.cs">
       <Link>Other\EntityType.cs</Link>
     </Compile>

+ 19 - 6
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -179,9 +179,9 @@ namespace MyEditor
 				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
 				if (innerConfig != null)
 				{
-					GUILayout.Label($"Host:");
+					GUILayout.Label($"InnerHost:");
 					innerConfig.Host = EditorGUILayout.TextField(innerConfig.Host);
-					GUILayout.Label($"Port:");
+					GUILayout.Label($"InnerPort:");
 					innerConfig.Port = EditorGUILayout.IntField(innerConfig.Port);
 				}
 
@@ -190,10 +190,18 @@ namespace MyEditor
 				{
 					GUILayout.Label($"OuterHost:");
 					outerConfig.Host = EditorGUILayout.TextField(outerConfig.Host);
-					GUILayout.Label($"OuterHost:");
+					GUILayout.Label($"OuterPort:");
 					outerConfig.Port = EditorGUILayout.IntField(outerConfig.Port);
 				}
 
+				ClientConfig clientConfig = startConfig.GetComponent<ClientConfig>();
+				if (clientConfig != null)
+				{
+					GUILayout.Label($"Host:");
+					clientConfig.Host = EditorGUILayout.TextField(clientConfig.Host);
+					GUILayout.Label($"Port:");
+					clientConfig.Port = EditorGUILayout.IntField(clientConfig.Port);
+				}
 
 				if (GUILayout.Button("删除"))
 				{
@@ -226,13 +234,18 @@ namespace MyEditor
 				StartConfig newStartConfig = new StartConfig();
 
 				newStartConfig.AppType = this.AppType;
-				newStartConfig.AddComponent<InnerConfig>();
-
-				if (this.AppType.Is(AppType.Gate) || this.AppType.Is(AppType.Realm) || this.AppType.Is(AppType.Manager))
+				
+				if (this.AppType.Is(AppType.Gate | AppType.Realm | AppType.Manager))
 				{
+					newStartConfig.AddComponent<InnerConfig>();
 					newStartConfig.AddComponent<OuterConfig>();
 				}
 
+				if (this.AppType.Is(AppType.Benchmark))
+				{
+					newStartConfig.AddComponent<ClientConfig>();
+				}
+
 				this.startConfigs.Add(newStartConfig);
 			}
 			GUILayout.EndHorizontal();

+ 3 - 4
Unity/Assets/Plugins/Base/Helper/RandomHelper.cs

@@ -4,10 +4,11 @@ namespace Base
 {
 	public static class RandomHelper
 	{
+		private static readonly Random random = new Random();
+
 		public static UInt64 RandUInt64()
 		{
 			var bytes = new byte[8];
-			Random random = new Random();
 			random.NextBytes(bytes);
 			return BitConverter.ToUInt64(bytes, 0);
 		}
@@ -15,7 +16,6 @@ namespace Base
 		public static Int64 RandInt64()
 		{
 			var bytes = new byte[8];
-			Random random = new Random();
 			random.NextBytes(bytes);
 			return BitConverter.ToInt64(bytes, 0);
 		}
@@ -28,8 +28,7 @@ namespace Base
 		/// <returns></returns>
 		public static int RandomNumber(int lower, int upper)
 		{
-			Random ra = new Random(Guid.NewGuid().GetHashCode());
-			int value = ra.Next(lower, upper);
+			int value = random.Next(lower, upper);
 			return value;
 		}
 	}

+ 10 - 1
Unity/Assets/Plugins/Base/Network/AChannel.cs

@@ -14,10 +14,18 @@ namespace Base
 		NoAllocate = 1 << 2
 	}
 
+	public enum ChannelType
+	{
+		Connect,
+		Accept,
+	}
+
 	public abstract class AChannel: IDisposable
 	{
 		public long Id { get; private set; }
 
+		public ChannelType ChannelType { get; }
+
 		protected AService service;
 
 		public string RemoteAddress { get; protected set; }
@@ -42,9 +50,10 @@ namespace Base
 		}
 
 
-		protected AChannel(AService service)
+		protected AChannel(AService service, ChannelType channelType)
 		{
 			this.Id = IdGenerater.GenerateId();
+			this.ChannelType = channelType;
 			this.service = service;
 		}
 		

+ 2 - 2
Unity/Assets/Plugins/Base/Network/TNet/TChannel.cs

@@ -21,7 +21,7 @@ namespace Base
 		/// <summary>
 		/// connect
 		/// </summary>
-		public TChannel(TSocket socket, string host, int port, TService service) : base(service)
+		public TChannel(TSocket socket, string host, int port, TService service) : base(service, ChannelType.Connect)
 		{
 			this.socket = socket;
 			this.parser = new PacketParser(this.recvBuffer);
@@ -39,7 +39,7 @@ namespace Base
 		/// <summary>
 		/// accept
 		/// </summary>
-		public TChannel(TSocket socket, TService service) : base(service)
+		public TChannel(TSocket socket, TService service) : base(service, ChannelType.Accept)
 		{
 			this.socket = socket;
 			this.parser = new PacketParser(this.recvBuffer);

+ 1 - 1
Unity/Assets/Plugins/Base/Network/TNet/TSocket.cs

@@ -65,7 +65,7 @@ namespace Base
 				return;
 			}
 			
-			this.socket.Dispose();
+			this.socket.Close();
 			this.innArgs.Dispose();
 			this.outArgs.Dispose();
 			this.socket = null;

+ 2 - 2
Unity/Assets/Plugins/Base/Network/UNet/UChannel.cs

@@ -15,7 +15,7 @@ namespace Base
 		/// <summary>
 		/// connect
 		/// </summary>
-		public UChannel(USocket socket, string host, int port, UService service): base(service)
+		public UChannel(USocket socket, string host, int port, UService service): base(service, ChannelType.Connect)
 		{
 			this.socket = socket;
 			this.service = service;
@@ -28,7 +28,7 @@ namespace Base
 		/// <summary>
 		/// accept
 		/// </summary>
-		public UChannel(USocket socket, UService service) : base(service)
+		public UChannel(USocket socket, UService service) : base(service, ChannelType.Accept)
 		{
 			this.socket = socket;
 			this.service = service;

+ 3 - 1
Unity/Assets/Plugins/Base/Network/UNet/USocket.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Net;
 using System.Runtime.InteropServices;
 
 namespace Base
@@ -73,7 +74,8 @@ namespace Base
 			get
 			{
 				ENetPeer peer = this.Struct;
-				return peer.Address.Host + ":" + peer.Address.Port;
+				IPAddress ipaddr = new IPAddress(peer.Address.Host);
+				return $"{ipaddr}:{peer.Address.Port}";
 			}
 		}
 

+ 2 - 2
Unity/Assets/Plugins/Base/Object/Component.cs

@@ -8,9 +8,9 @@ namespace Base
 	public abstract class Component : Object
 	{
 		[BsonIgnore]
-		public Entity Owner { protected get; set; }
+		public Entity Owner { get; set; }
 
-		protected T GetOwner<T>() where T: Entity
+		public T GetOwner<T>() where T: Entity
 		{
 			return this.Owner as T;
 		}

+ 73 - 0
Unity/Assets/Scripts/Component/BenchmakComponent.cs

@@ -0,0 +1,73 @@
+using System;
+using Base;
+
+namespace Model
+{
+	[ObjectEvent]
+	public class BenchmakComponentEvent : ObjectEvent<BenchmakComponent>, IAwake<string>
+	{
+		public void Awake(string address)
+		{
+			BenchmakComponent component = this.GetValue();
+			component.Awake(address);
+		}
+	}
+
+	public class BenchmakComponent : Component
+	{
+		private int k;
+
+		public void Awake(string address)
+		{
+			NetworkComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
+
+			for (int i = 0; i < 400; i++)
+			{
+				TestAsync(networkComponent, address, i);
+			}
+		}
+
+		private async void TestAsync(NetworkComponent networkComponent, string address, int j)
+		{
+			using (Session session = networkComponent.Create(address))
+			{
+				int i = 0;
+				while (i < 10000)
+				{
+					++i;
+					try
+					{
+						R2C_Login s2CLogin = await session.Call<C2R_Login, R2C_Login>(new C2R_Login { Account = "abcdef", Password = "111111" });
+						
+						Session gateSession = networkComponent.Get(s2CLogin.Address);
+						await gateSession.Call<C2G_LoginGate, G2C_LoginGate>(new C2G_LoginGate(s2CLogin.Key));
+
+						++this.k;
+						if (this.k % 1000 == 0)
+						{
+							Log.Info($"{j} Benchmark k: {k}");
+						}
+					}
+					catch (RpcException e)
+					{
+						Log.Error(e.ToString());
+					}
+					catch (Exception e)
+					{
+						Log.Error(e.ToString());
+					}
+				}
+			}
+		}
+
+		public override void Dispose()
+		{
+			if (this.Id == 0)
+			{
+				return;
+			}
+
+			base.Dispose();
+		}
+    }
+}

+ 12 - 0
Unity/Assets/Scripts/Component/BenchmakComponent.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: c5ad06ffe2931aa4f897be9193d6e024
+timeCreated: 1478068700
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 4
Unity/Assets/Scripts/Component/NetworkComponent.cs

@@ -69,10 +69,9 @@ namespace Model
 
 				AChannel channel = await this.Service.AcceptChannel();
 
-				Session session = new Session(this.GetOwner<Scene>(), channel);
+				Session session = new Session(this, channel);
 				channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
 				this.sessions.Add(session.Id, session);
-				this.AddToAddressDict(session);
 			}
 		}
 		
@@ -96,7 +95,10 @@ namespace Model
 			}
 			removeCallback.Invoke(session);
 			this.sessions.Remove(id);
-			this.adressSessions.Remove(session.RemoteAddress);
+			if (session.ChannelType == ChannelType.Connect)
+			{
+				this.adressSessions.Remove(session.RemoteAddress);
+			}
 			session.Dispose();
 		}
 
@@ -132,7 +134,7 @@ namespace Model
 			int port = int.Parse(ss[1]);
 			string host = ss[0];
 			AChannel channel = this.Service.ConnectChannel(host, port);
-			Session session = new Session(this.GetOwner<Scene>(), channel);
+			Session session = new Session(this, channel);
 			channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
 			this.sessions.Add(session.Id, session);
 			return session;

+ 16 - 5
Unity/Assets/Scripts/Entity/Session.cs

@@ -9,13 +9,13 @@ namespace Model
 	public sealed class Session: Entity
 	{
 		private static uint RpcId { get; set; }
-		private readonly Scene scene;
+		private readonly NetworkComponent network;
 		private readonly Dictionary<uint, Action<byte[], int, int>> requestCallback = new Dictionary<uint, Action<byte[], int, int>>();
 		private readonly AChannel channel;
 
-		public Session(Scene scene, AChannel channel) : base(EntityType.Session)
+		public Session(NetworkComponent network, AChannel channel) : base(EntityType.Session)
 		{
-			this.scene = scene;
+			this.network = network;
 			this.channel = channel;
 			this.StartRecv();
 		}
@@ -28,6 +28,14 @@ namespace Model
 			}
 		}
 
+		public ChannelType ChannelType
+		{
+			get
+			{
+				return this.channel.ChannelType;
+			}
+		}
+
 		private async void StartRecv()
 		{
 			while (true)
@@ -91,7 +99,7 @@ namespace Model
 			if (rpcFlag == 0)
 			{
 				MessageInfo messageInfo = new MessageInfo(opcode, messageBytes, offset, rpcId);
-				this.scene.GetComponent<MessageDispatherComponent>().Handle(this, messageInfo);
+				this.network.Owner.GetComponent<MessageDispatherComponent>().Handle(this, messageInfo);
 				return;
 			}
 
@@ -191,7 +199,7 @@ namespace Model
 
 		private void SendMessage(uint rpcId, object message, bool isCall = true)
 		{
-			ushort opcode = this.scene.GetComponent<MessageDispatherComponent>().GetOpcode(message.GetType());
+			ushort opcode = this.network.Owner.GetComponent<MessageDispatherComponent>().GetOpcode(message.GetType());
 			byte[] opcodeBytes = BitConverter.GetBytes(opcode);
 			if (!isCall)
 			{
@@ -221,9 +229,12 @@ namespace Model
 				return;
 			}
 
+			long id = this.Id;
+
 			base.Dispose();
 			
 			this.channel.Dispose();
+			this.network.Remove(id);
 		}
 	}
 }

+ 3 - 1
Unity/Assets/Scripts/Message/AppType.cs

@@ -12,7 +12,9 @@ namespace Model
 		Gate = 4,
 		// 7
 		AllServer = Manager | Realm | Gate,
-		
+
+		Benchmark,
+
 		Client,
 		Robot,
 	}

+ 1 - 0
Unity/Assets/Scripts/Other/BsonClassMapRegister.cs

@@ -16,6 +16,7 @@ namespace Model
 
 			BsonClassMap.RegisterClassMap<InnerConfig>();
 			BsonClassMap.RegisterClassMap<OuterConfig>();
+			BsonClassMap.RegisterClassMap<ClientConfig>();
 		}
 	}
 }

+ 4 - 2
Unity/Assets/Scripts/Other/ClientConfig.cs

@@ -1,8 +1,10 @@
-using MongoDB.Bson.Serialization.Attributes;
+using Base;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {
-	public class ClientConfig
+	[BsonIgnoreExtraElements]
+	public class ClientConfig: Component
 	{
 		public string Host = "";
 		public int Port;

+ 1 - 0
Unity/Assets/Scripts/Other/EntityType.cs

@@ -7,5 +7,6 @@
 		public const string Session = "Session";
 		public const string UI = "UI";
 		public const string Config = "Config";
+		public const string Network = "Network";
 	}
 }

+ 5 - 5
Unity/Unity.CSharp.csproj

@@ -79,10 +79,10 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Assets\Scripts\Component\ConfigComponent.cs" />
-    <Compile Include="Assets\Scripts\Component\RobotComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\BenchmakComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ChildrenComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ClientConfigComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\ConfigComponent.cs" />
     <Compile Include="Assets\Scripts\Component\EventComponent.cs" />
     <Compile Include="Assets\Scripts\Component\GameObjectComponent.cs" />
     <Compile Include="Assets\Scripts\Component\KVComponent.cs" />
@@ -90,6 +90,7 @@
     <Compile Include="Assets\Scripts\Component\NetInnerComponent.cs" />
     <Compile Include="Assets\Scripts\Component\NetOuterComponent.cs" />
     <Compile Include="Assets\Scripts\Component\NetworkComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\RobotComponent.cs" />
     <Compile Include="Assets\Scripts\Component\TimeComponent.cs" />
     <Compile Include="Assets\Scripts\Component\TimerComponent.cs" />
     <Compile Include="Assets\Scripts\Config\ACategory.cs" />
@@ -97,7 +98,6 @@
     <Compile Include="Assets\Scripts\Config\ConfigAttribute.cs" />
     <Compile Include="Assets\Scripts\Config\ConfigHelper.cs" />
     <Compile Include="Assets\Scripts\Config\ICategory.cs" />
-    <Compile Include="Assets\Scripts\Model\Config\BuffConfig.cs" />
     <Compile Include="Assets\Scripts\Entity\Game.cs" />
     <Compile Include="Assets\Scripts\Entity\Scene.cs" />
     <Compile Include="Assets\Scripts\Entity\Session.cs" />
@@ -116,11 +116,12 @@
     <Compile Include="Assets\Scripts\Message\AppType.cs" />
     <Compile Include="Assets\Scripts\Message\ErrorCode.cs" />
     <Compile Include="Assets\Scripts\Message\IMHandler.cs" />
-    <Compile Include="Assets\Scripts\Model\Message\Message.cs" />
     <Compile Include="Assets\Scripts\Message\MessageAttribute.cs" />
     <Compile Include="Assets\Scripts\Message\MessageHandlerAttribute.cs" />
     <Compile Include="Assets\Scripts\Message\OpcodeHelper.cs" />
     <Compile Include="Assets\Scripts\Message\RpcException.cs" />
+    <Compile Include="Assets\Scripts\Model\Config\BuffConfig.cs" />
+    <Compile Include="Assets\Scripts\Model\Message\Message.cs" />
     <Compile Include="Assets\Scripts\Other\BsonClassMapRegister.cs" />
     <Compile Include="Assets\Scripts\Other\ClientConfig.cs" />
     <Compile Include="Assets\Scripts\Other\EntityType.cs" />
@@ -134,6 +135,5 @@
     <None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\AsyncBridge.Net35.xml" />
     <None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\System.Threading.xml" />
   </ItemGroup>
-  <ItemGroup />
   <Import Project="$(MSBuildExtensionsPath)\SyntaxTree\UnityVS\2015\UnityVS.CSharp.targets" />
 </Project>