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

统一Websocket,TCP,KCP代码,使用方式完全一样

tanghai 7 лет назад
Родитель
Сommit
776db5ae37

+ 9 - 9
Config/StartConfig/127.0.0.1.txt

@@ -1,9 +1,9 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10000, "Host2" : "127.0.0.1" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565862653976"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 10001 }], "AppId" : 2, "AppType" : "Location", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20001 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : "127.0.0.1" }], "AppId" : 3, "AppType" : "Realm", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20002 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10003, "Host2" : "127.0.0.1" }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20003 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10004, "Host2" : "127.0.0.1" }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20004 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10005, "Host2" : "127.0.0.1" }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20005 }, { "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10006, "Host2" : "127.0.0.1" }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20006 }], "AppId" : 8, "AppType" : "Map", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20007 }], "AppId" : 9, "AppType" : "Map", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10000", "Address2" : "127.0.0.1:10000" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565862653976"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:10001" }], "AppId" : 2, "AppType" : "Location", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20001" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }], "AppId" : 3, "AppType" : "Realm", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20002" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10003", "Address2" : "127.0.0.1:10003" }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20003" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10004", "Address2" : "127.0.0.1:10004" }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20004" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10005", "Address2" : "127.0.0.1:10005" }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20005" }, { "_t" : "OuterConfig", "Address" : "127.0.0.1:10006", "Address2" : "127.0.0.1:10006" }], "AppId" : 7, "AppType" : "Gate", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20006" }], "AppId" : 8, "AppType" : "Map", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98565723062316"), "C" : [{ "_t" : "InnerConfig", "Address" : "127.0.0.1:20007" }], "AppId" : 9, "AppType" : "Map", "ServerIP" : "*" }

+ 2 - 2
Config/StartConfig/Benchmark.txt

@@ -1,2 +1,2 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : null }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("98892711264291"), "C" : [{ "_t" : "ClientConfig", "Host" : "127.0.0.1", "Port" : 10002 }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "C" : [{ "_t" : "ClientConfig", "Address" : "127.0.0.1:10002" }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" }

+ 3 - 0
Config/StartConfig/BenchmarkWebsocket.txt

@@ -0,0 +1,3 @@
+{ "_t" : "StartConfig", "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "C" : [{ "_t" : "OuterConfig", "Address" : "http://*:8080/", "Address2" : "ws://127.0.0.1:8080" }], "AppId" : 2, "AppType" : "BenchmarkWebsocketServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "C" : [{ "_t" : "ClientConfig", "Address" : "ws://127.0.0.1:8080" }], "AppId" : 3, "AppType" : "BenchmarkWebsocketClient", "ServerIP" : "*" }

+ 1 - 1
Config/StartConfig/LocalAllServer.txt

@@ -1 +1 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : "127.0.0.1" }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 19 - 15
Server/App/Program.cs

@@ -48,33 +48,32 @@ namespace App
 				switch (startConfig.AppType)
 				{
 					case AppType.Manager:
-						//Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
-						//Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
-						Game.Scene.AddComponent<NetOuterComponent, List<string>>(new List<string>() {"http://*:8080/"});
 						Game.Scene.AddComponent<AppManagerComponent>();
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						break;
 					case AppType.Realm:
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
-						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
 						break;
 					case AppType.Gate:
 						Game.Scene.AddComponent<PlayerComponent>();
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
-						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						break;
 					case AppType.Location:
-						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<LocationComponent>();
 						break;
 					case AppType.Map:
-						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<UnitComponent>();
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<ActorMessageSenderComponent>();
@@ -90,8 +89,8 @@ namespace App
 						Game.Scene.AddComponent<DBCacheComponent>();
 						Game.Scene.AddComponent<LocationComponent>();
 						Game.Scene.AddComponent<ActorMessageDispatherComponent>();
-						Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(innerConfig.IPEndPoint);
-						Game.Scene.AddComponent<NetOuterComponent, IPEndPoint>(outerConfig.IPEndPoint);
+						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
 						Game.Scene.AddComponent<AppManagerComponent>();
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
@@ -101,10 +100,15 @@ namespace App
 						// Game.Scene.AddComponent<HttpComponent>();
 						break;
 					case AppType.Benchmark:
-						//Game.Scene.AddComponent<NetOuterComponent>();
-						//Game.Scene.AddComponent<BenchmarkComponent, IPEndPoint>(clientConfig.IPEndPoint);
-						Game.Scene.AddComponent<NetOuterComponent>();
-						Game.Scene.AddComponent<WebSocketBenchmarkComponent>();
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol>(options.Protocol);
+						Game.Scene.AddComponent<BenchmarkComponent, string>(clientConfig.Address);
+						break;
+					case AppType.BenchmarkWebsocketServer:
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(NetworkProtocol.WebSocket, outerConfig.Address);
+						break;
+					case AppType.BenchmarkWebsocketClient:
+						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol>(NetworkProtocol.WebSocket);
+						Game.Scene.AddComponent<WebSocketBenchmarkComponent, string>(clientConfig.Address);
 						break;
 					default:
 						throw new Exception($"命令行参数没有设置正确的AppType: {startConfig.AppType}");

+ 4 - 3
Server/Hotfix/Module/Benchmark/BenchmarkComponentSystem.cs

@@ -6,9 +6,9 @@ using ETModel;
 namespace ETHotfix
 {
 	[ObjectSystem]
-	public class BenchmarkComponentSystem : AwakeSystem<BenchmarkComponent, IPEndPoint>
+	public class BenchmarkComponentSystem : AwakeSystem<BenchmarkComponent, string>
 	{
-		public override void Awake(BenchmarkComponent self, IPEndPoint a)
+		public override void Awake(BenchmarkComponent self, string a)
 		{
 			self.Awake(a);
 		}
@@ -16,10 +16,11 @@ namespace ETHotfix
 
 	public static class BenchmarkComponentHelper
 	{
-		public static void Awake(this BenchmarkComponent self, IPEndPoint ipEndPoint)
+		public static void Awake(this BenchmarkComponent self, string address)
 		{
 			try
 			{
+				IPEndPoint ipEndPoint = NetworkHelper.ToIPEndPoint(address);
 				NetOuterComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
 				for (int i = 0; i < 1000; i++)
 				{

+ 7 - 7
Server/Hotfix/Module/Benchmark/WebSocketBenchmarkComponentSystem.cs

@@ -5,24 +5,24 @@ using ETModel;
 namespace ETHotfix
 {
 	[ObjectSystem]
-	public class WebSocketBenchmarkComponentSystem : AwakeSystem<WebSocketBenchmarkComponent>
+	public class WebSocketBenchmarkComponentSystem : AwakeSystem<WebSocketBenchmarkComponent, string>
 	{
-		public override void Awake(WebSocketBenchmarkComponent self)
+		public override void Awake(WebSocketBenchmarkComponent self, string address)
 		{
-			self.Awake();
+			self.Awake(address);
 		}
 	}
 
 	public static class WebSocketBenchmarkComponentHelper
 	{
-		public static void Awake(this WebSocketBenchmarkComponent self)
+		public static void Awake(this WebSocketBenchmarkComponent self, string address)
 		{
 			try
 			{
 				NetOuterComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
 				for (int i = 0; i < 1000; i++)
 				{
-					self.TestAsync(networkComponent, i);
+					self.TestAsync(networkComponent, i, address);
 				}
 			}
 			catch (Exception e)
@@ -31,11 +31,11 @@ namespace ETHotfix
 			}
 		}
 		
-		public static async void TestAsync(this WebSocketBenchmarkComponent self, NetOuterComponent networkComponent, int j)
+		public static async void TestAsync(this WebSocketBenchmarkComponent self, NetOuterComponent networkComponent, int j, string address)
 		{
 			try
 			{
-				using (Session session = networkComponent.Create($"ws://127.0.0.1:8080"))
+				using (Session session = networkComponent.Create(address))
 				{
 					int i = 0;
 					while (i < 100000000)

+ 1 - 1
Server/Hotfix/Module/FrameSync/C2R_LoginHandler.cs

@@ -29,7 +29,7 @@ namespace ETHotfix
 				// 向gate请求一个key,客户端可以拿着这个key连接gate
 				G2R_GetLoginKey g2RGetLoginKey = (G2R_GetLoginKey)await gateSession.Call(new R2G_GetLoginKey() {Account = message.Account});
 
-				string outerAddress = config.GetComponent<OuterConfig>().IPEndPoint2.ToString();
+				string outerAddress = config.GetComponent<OuterConfig>().Address2;
 
 				response.Address = outerAddress;
 				response.Key = g2RGetLoginKey.Key;

+ 4 - 4
Server/Hotfix/Module/Message/NetInnerComponentSystem.cs

@@ -13,9 +13,9 @@ namespace ETHotfix
 	}
 
 	[ObjectSystem]
-	public class NetInnerComponentAwake1System : AwakeSystem<NetInnerComponent, IPEndPoint>
+	public class NetInnerComponentAwake1System : AwakeSystem<NetInnerComponent, string>
 	{
-		public override void Awake(NetInnerComponent self, IPEndPoint a)
+		public override void Awake(NetInnerComponent self, string a)
 		{
 			self.Awake(a);
 		}
@@ -40,9 +40,9 @@ namespace ETHotfix
 			self.AppType = StartConfigComponent.Instance.StartConfig.AppType;
 		}
 
-		public static void Awake(this NetInnerComponent self, IPEndPoint ipEndPoint)
+		public static void Awake(this NetInnerComponent self, string address)
 		{
-			self.Awake(NetworkProtocol.TCP, ipEndPoint);
+			self.Awake(NetworkProtocol.TCP, address);
 			self.MessagePacker = new MongoPacker();
 			self.MessageDispatcher = new InnerMessageDispatcher();
 			self.AppType = StartConfigComponent.Instance.StartConfig.AppType;

+ 6 - 17
Server/Hotfix/Module/Message/NetOuterComponentSystem.cs

@@ -5,38 +5,27 @@ using ETModel;
 namespace ETHotfix
 {
 	[ObjectSystem]
-	public class NetOuterComponentAwakeSystem : AwakeSystem<NetOuterComponent>
+	public class NetOuterComponentAwakeSystem : AwakeSystem<NetOuterComponent, NetworkProtocol>
 	{
-		public override void Awake(NetOuterComponent self)
+		public override void Awake(NetOuterComponent self, NetworkProtocol protocol)
 		{
-			self.Awake(NetworkProtocol.WebSocket);
+			self.Awake(protocol);
 			self.MessagePacker = new ProtobufPacker();
 			self.MessageDispatcher = new OuterMessageDispatcher();
 		}
 	}
 
 	[ObjectSystem]
-	public class NetOuterComponentAwake1System : AwakeSystem<NetOuterComponent, IPEndPoint>
+	public class NetOuterComponentAwake1System : AwakeSystem<NetOuterComponent, NetworkProtocol, string>
 	{
-		public override void Awake(NetOuterComponent self, IPEndPoint ipEndPoint)
+		public override void Awake(NetOuterComponent self, NetworkProtocol protocol, string address)
 		{
-			self.Awake(NetworkProtocol.TCP, ipEndPoint);
+			self.Awake(protocol, address);
 			self.MessagePacker = new ProtobufPacker();
 			self.MessageDispatcher = new OuterMessageDispatcher();
 		}
 	}
 	
-	[ObjectSystem]
-	public class NetOuterComponentAwake2System : AwakeSystem<NetOuterComponent, List<string>>
-	{
-		public override void Awake(NetOuterComponent self, List<string> prefixs)
-		{
-			self.Awake(NetworkProtocol.WebSocket, prefixs);
-			self.MessagePacker = new ProtobufPacker();
-			self.MessageDispatcher = new OuterMessageDispatcher();
-		}
-	}
-
 	[ObjectSystem]
 	public class NetOuterComponentUpdateSystem : UpdateSystem<NetOuterComponent>
 	{

+ 3 - 0
Server/Model/Other/Options.cs

@@ -15,5 +15,8 @@ namespace ETModel
 
 		[Option("config", Required = false, Default = "../Config/StartConfig/LocalAllServer.txt")]
 		public string Config { get; set; }
+		
+		[Option("protocol", Required = false, Default = NetworkProtocol.TCP)]
+		public NetworkProtocol Protocol { get; set; }
 	}
 }

+ 26 - 22
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -179,46 +179,40 @@ namespace ETEditor
 				StartConfig startConfig = this.startConfigs[i];
 				GUILayout.BeginHorizontal();
 				GUILayout.Label($"AppId:");
-				startConfig.AppId = EditorGUILayout.IntField(startConfig.AppId);
+				startConfig.AppId = EditorGUILayout.IntField(startConfig.AppId, GUILayout.Width(30));
 				GUILayout.Label($"服务器IP:");
-				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP);
+				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP, GUILayout.Width(100));
 				GUILayout.Label($"AppType:");
 				startConfig.AppType = (AppType) EditorGUILayout.EnumPopup(startConfig.AppType);
 
 				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
 				if (innerConfig != null)
 				{
-					GUILayout.Label($"InnerHost:");
-					innerConfig.Host = EditorGUILayout.TextField(innerConfig.Host);
-					GUILayout.Label($"InnerPort:");
-					innerConfig.Port = EditorGUILayout.IntField(innerConfig.Port);
+					GUILayout.Label($"Address:");
+					innerConfig.Address = EditorGUILayout.TextField(innerConfig.Address, GUILayout.Width(120));
 				}
 
 				OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();
 				if (outerConfig != null)
 				{
-					GUILayout.Label($"OuterHost:");
-					outerConfig.Host = EditorGUILayout.TextField(outerConfig.Host);
-					GUILayout.Label($"OuterHost2:");
-					outerConfig.Host2 = EditorGUILayout.TextField(outerConfig.Host2);
-					GUILayout.Label($"OuterPort:");
-					outerConfig.Port = EditorGUILayout.IntField(outerConfig.Port);
+					GUILayout.Label($"Address:");
+					outerConfig.Address = EditorGUILayout.TextField(outerConfig.Address, GUILayout.Width(120));
+					GUILayout.Label($"Address2:");
+					outerConfig.Address2 = EditorGUILayout.TextField(outerConfig.Address2, GUILayout.Width(120));
 				}
 
 				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);
+					GUILayout.Label($"Address:");
+					clientConfig.Address = EditorGUILayout.TextField(clientConfig.Address, GUILayout.Width(120));
 				}
 
 				HttpConfig httpConfig = startConfig.GetComponent<HttpConfig>();
 				if (httpConfig != null)
 				{
 					GUILayout.Label($"AppId:");
-					httpConfig.AppId = EditorGUILayout.IntField(httpConfig.AppId);
+					httpConfig.AppId = EditorGUILayout.IntField(httpConfig.AppId, GUILayout.Width(20));
 					GUILayout.Label($"AppKey:");
 					httpConfig.AppKey = EditorGUILayout.TextField(httpConfig.AppKey);
 					GUILayout.Label($"Url:");
@@ -309,11 +303,6 @@ namespace ETEditor
 					newStartConfig.AddComponent<InnerConfig>();
 				}
 
-				if (this.AppType.Is(AppType.Benchmark))
-				{
-					newStartConfig.AddComponent<ClientConfig>();
-				}
-
 				if (this.AppType.Is(AppType.Http))
 				{
 					newStartConfig.AddComponent<HttpConfig>();
@@ -323,6 +312,21 @@ namespace ETEditor
 				{
 					newStartConfig.AddComponent<DBConfig>();
 				}
+				
+				if (this.AppType.Is(AppType.Benchmark))
+				{
+					newStartConfig.AddComponent<ClientConfig>();
+				}
+				
+				if (this.AppType.Is(AppType.BenchmarkWebsocketServer))
+				{
+					newStartConfig.AddComponent<OuterConfig>();
+				}
+				
+				if (this.AppType.Is(AppType.BenchmarkWebsocketClient))
+				{
+					newStartConfig.AddComponent<ClientConfig>();
+				}
 
 				this.startConfigs.Add(newStartConfig);
 			}

+ 1 - 21
Unity/Assets/Scripts/Component/Config/ClientConfig.cs

@@ -5,26 +5,6 @@ namespace ETModel
 {
 	public class ClientConfig: AConfigComponent
 	{
-		public string Host = "";
-		public int Port;
-
-		[BsonIgnore]
-		private IPEndPoint ipEndPoint;
-
-		public override void EndInit()
-		{
-			base.EndInit();
-
-			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
-		}
-
-		[BsonIgnore]
-		public IPEndPoint IPEndPoint
-		{
-			get
-			{
-				return this.ipEndPoint;
-			}
-		}
+		public string Address { get; set; }
 	}
 }

+ 4 - 16
Unity/Assets/Scripts/Component/Config/InnerConfig.cs

@@ -6,26 +6,14 @@ namespace ETModel
 	[BsonIgnoreExtraElements]
 	public class InnerConfig: AConfigComponent
 	{
-		public string Host { get; set; }
-		public int Port { get; set; }
-
 		[BsonIgnore]
-		private IPEndPoint ipEndPoint;
+		public IPEndPoint IPEndPoint { get; private set; }
+		
+		public string Address { get; set; }
 
 		public override void EndInit()
 		{
-			base.EndInit();
-
-			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
-		}
-
-		[BsonIgnore]
-		public IPEndPoint IPEndPoint
-		{
-			get
-			{
-				return this.ipEndPoint;
-			}
+			this.IPEndPoint = NetworkHelper.ToIPEndPoint(this.Address);
 		}
 	}
 }

+ 2 - 41
Unity/Assets/Scripts/Component/Config/OuterConfig.cs

@@ -6,46 +6,7 @@ namespace ETModel
 	[BsonIgnoreExtraElements]
 	public class OuterConfig: AConfigComponent
 	{
-		public string Host { get; set; }
-		public int Port { get; set; }
-
-		public string Host2 { get; set; }
-
-		[BsonIgnore]
-		private IPEndPoint ipEndPoint;
-
-		[BsonIgnore]
-		private IPEndPoint ipEndPoint2;
-
-		public override void EndInit()
-		{
-			base.EndInit();
-
-			if (this.Host2 == null)
-			{
-				this.Host2 = this.Host;
-			}
-
-			this.ipEndPoint = NetworkHelper.ToIPEndPoint(this.Host, this.Port);
-			this.ipEndPoint2 = NetworkHelper.ToIPEndPoint(this.Host2, this.Port);
-		}
-
-		[BsonIgnore]
-		public IPEndPoint IPEndPoint
-		{
-			get
-			{
-				return this.ipEndPoint;
-			}
-		}
-
-		[BsonIgnore]
-		public IPEndPoint IPEndPoint2
-		{
-			get
-			{
-				return this.ipEndPoint2;
-			}
-		}
+		public string Address { get; set; }
+		public string Address2 { get; set; }
 	}
 }

+ 11 - 22
Unity/Assets/Scripts/Module/Message/NetworkComponent.cs

@@ -46,38 +46,28 @@ namespace ETModel
 			}
 		}
 
-		public void Awake(NetworkProtocol protocol, IPEndPoint ipEndPoint)
+		public void Awake(NetworkProtocol protocol, string address)
 		{
 			try
 			{
+				IPEndPoint ipEndPoint;
 				switch (protocol)
 				{
 					case NetworkProtocol.KCP:
+						ipEndPoint = NetworkHelper.ToIPEndPoint(address);
 						this.Service = new KService(ipEndPoint);
 						break;
 					case NetworkProtocol.TCP:
+						ipEndPoint = NetworkHelper.ToIPEndPoint(address);
 						this.Service = new TService(ipEndPoint);
 						break;
-					default:
-						throw new ArgumentOutOfRangeException();
-				}
-				
-				this.Service.AcceptCallback += this.OnAccept;
-				
-				this.Start();
-			}
-			catch (Exception e)
-			{
-				throw new Exception($"{ipEndPoint}", e);
-			}
-		}
-
 #if SERVER
-		public void Awake(NetworkProtocol protocol, List<string> prefixs)
-		{
-			try
-			{
-				this.Service = new WService(prefixs);
+					case NetworkProtocol.WebSocket:
+						string[] prefixs = address.Split(';');
+						this.Service = new WService(prefixs);
+						break;
+#endif
+				}
 				
 				this.Service.AcceptCallback += this.OnAccept;
 				
@@ -85,10 +75,9 @@ namespace ETModel
 			}
 			catch (Exception e)
 			{
-				throw new Exception($"websocket error: {prefixs}", e);
+				throw new Exception($"NetworkComponent Awake Error {address}", e);
 			}
 		}
-#endif
 
 		public void Start()
 		{

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

@@ -15,12 +15,14 @@ namespace ETModel
 		Location = 1 << 5,
 		Map = 1 << 6,
 
+		BenchmarkWebsocketServer = 1 << 27,
+		BenchmarkWebsocketClient = 1 << 28,
 		Robot = 1 << 29,
 		Benchmark = 1 << 30,
 		Client = 1 << 31,
 
 		// 7
-		AllServer = Manager | Realm | Gate | Http | DB | Location | Map
+		AllServer = Manager | Realm | Gate | Http | DB | Location | Map | BenchmarkWebsocketServer
 	}
 
 	public static class AppTypeHelper