瀏覽代碼

1.提供将所有App功能合并到一个进程的功能,AppType=AllServer表示这个进程可以充当所有server,调试非常方便
2.编译调试目录改成Egametang目录
3.启动配置可以用命令行编辑器随时添加切换

tanghai 9 年之前
父節點
當前提交
172ec9d951
共有 46 個文件被更改,包括 214 次插入116 次删除
  1. 1 0
      .gitignore
  2. 5 0
      Build.sh
  3. 2 3
      CMakeLists.txt
  4. 0 1
      Config/Rsync/rsyncConfig.txt
  5. 1 0
      Config/StartConfig/127.0.0.1.txt
  6. 6 0
      Config/StartConfig/192.168.1.134.txt
  7. 6 0
      Config/StartConfig/192.168.12.188.txt
  8. 9 0
      Run.sh
  9. 6 0
      Server/App/Program.cs
  10. 3 8
      Server/App/Server.App.csproj
  11. 0 5
      Server/App/Start.txt
  12. 3 3
      Server/Base/Server.Base.csproj
  13. 0 5
      Server/Build.sh
  14. 1 1
      Server/Controller/Message/M2A_ReloadHandler.cs
  15. 2 2
      Server/Controller/Server.Controller.csproj
  16. 4 4
      Server/Model/Component/AppManagerComponent.cs
  17. 1 1
      Server/Model/Component/RealmGateAddressComponent.cs
  18. 9 8
      Server/Model/Component/StartConfigComponent.cs
  19. 2 2
      Server/Model/Server.Model.csproj
  20. 0 9
      Server/Run.sh
  21. 16 0
      Server/Server.sln
  22. 6 5
      Server/ThirdParty/ENet/ENet.vcxproj
  23. 2 2
      Start.sh
  24. 0 0
      Tools/Config/.emacs
  25. 0 0
      Tools/Config/.gitconfig
  26. 0 0
      Tools/Config/.screenrc
  27. 0 0
      Tools/Config/Egametang.ffs_batch
  28. 0 0
      Tools/Config/Egametang.ffs_gui
  29. 0 0
      Tools/Config/Unity.sln.DotSettings
  30. 0 0
      Tools/Config/VS.vssettings
  31. 0 0
      Tools/Config/eclipse.epf
  32. 2 2
      Tools/cwRsync/Config/exclude.txt
  33. 0 0
      Tools/cwRsync/Config/rsync.secrets
  34. 1 0
      Tools/cwRsync/Config/rsyncConfig.txt
  35. 0 0
      Tools/cwRsync/Config/rsyncd.conf
  36. 0 0
      Tools/cwRsync/Config/rsyncd.secrets
  37. 6 6
      Unity/Assets/Editor/RsyncEditor/RsyncEditor.cs
  38. 75 15
      Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs
  39. 0 2
      Unity/Assets/Plugins/Base/Network/UNet/UChannel.cs
  40. 2 1
      Unity/Assets/Plugins/Base/Object/Entity.cs
  41. 7 0
      Unity/Assets/Scripts/Component/NetworkComponent.cs
  42. 18 6
      Unity/Assets/Scripts/Message/AppType.cs
  43. 4 7
      Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs
  44. 5 13
      Unity/Assets/Scripts/Other/Options.cs
  45. 6 4
      Unity/Assets/Scripts/Other/StartConfig.cs
  46. 3 1
      Unity/Unity.sln

+ 1 - 0
.gitignore

@@ -31,3 +31,4 @@ _ReSharper.CSharp/
 /CSharp/CSharp.VC.opendb
 /Server/Server.VC.opendb
 /Log
+/Temp

+ 5 - 0
Build.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+xbuild ./Server/Server.sln
+cd Bin
+cmake ../
+make

+ 2 - 3
Server/CMakeLists.txt → CMakeLists.txt

@@ -9,10 +9,9 @@ ENDIF()
 PROJECT(CSharp)
 
 # 设置头文件查找路径
-INCLUDE_DIRECTORIES(ThirdParty/ENet)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/Platform)
+INCLUDE_DIRECTORIES(Server/ThirdParty/ENet)
 
 ADD_DEFINITIONS(-DHAS_SOCKLEN_T)
 
 # 子目录
-ADD_SUBDIRECTORY(ThirdParty/ENet)
+ADD_SUBDIRECTORY(Server/ThirdParty/ENet)

+ 0 - 1
Config/Rsync/rsyncConfig.txt

@@ -1 +0,0 @@
-{ "_t" : "RsyncConfig", "Host" : "192.168.12.188", "Account" : "tanghai", "Password" : "1234567890", "RelativePath" : "Source/Egametang", "Exclude" : [".git/", "Log/", "Tools/", "Server/Bin/", "Server/packages/", "Server/Temp/", "Server/Server.sdf", "Unity/Library/", "Unity/Temp/", "*/obj"] }

+ 1 - 0
Config/StartConfig/127.0.0.1.txt

@@ -0,0 +1 @@
+{ "_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" : "*" }

+ 6 - 0
Config/StartConfig/192.168.1.134.txt

@@ -0,0 +1,6 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20000 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10000 }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "192.168.1.134" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20001 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10001 }], "AppId" : 2, "AppType" : "Realm", "ServerIP" : "192.168.1.134" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20002 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10002 }], "AppId" : 3, "AppType" : "Gate", "ServerIP" : "192.168.1.134" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20003 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10003 }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "192.168.1.134" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20004 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10004 }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "192.168.1.134" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.1.134", "Port" : 20005 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.1.134", "Port" : 10005 }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "192.168.1.134" }

+ 6 - 0
Config/StartConfig/192.168.12.188.txt

@@ -0,0 +1,6 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20000 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10000 }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "192.168.12.188" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20001 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10001 }], "AppId" : 2, "AppType" : "Realm", "ServerIP" : "192.168.12.188" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20002 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10002 }], "AppId" : 3, "AppType" : "Gate", "ServerIP" : "192.168.12.188" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20003 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10003 }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "192.168.12.188" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20004 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10004 }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "192.168.12.188" }
+{ "_t" : "StartConfig", "_id" : NumberLong("96832366182401"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("96832366182402"), "Host" : "192.168.12.188", "Port" : 20005 }, { "_t" : "OuterConfig", "_id" : NumberLong("96832366182403"), "Host" : "192.168.12.188", "Port" : 10005 }], "AppId" : 6, "AppType" : "Gate", "ServerIP" : "192.168.12.188" }

+ 9 - 0
Run.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+xbuild ./Server/Server.sln
+cd Bin
+cmake ..
+make
+
+ps -ef | grep App.exe | awk '{print $2}' | xargs kill -9
+mono --debug App.exe --appId=1 --appType=Manager --config=../$1

+ 6 - 0
Server/App/Program.cs

@@ -50,6 +50,12 @@ namespace App
 						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						break;
+					case AppType.AllServer:
+						Game.Scene.AddComponent<NetOuterComponent, string, int>(outerConfig.Host, outerConfig.Port);
+						Game.Scene.AddComponent<AppManagerComponent>();
+						Game.Scene.AddComponent<RealmGateAddressComponent>();
+						Game.Scene.AddComponent<GateSessionKeyComponent>();
+						break;
 					default:
 						throw new Exception($"命令行参数没有设置正确的AppType: {startConfig.AppType}");
 				}

+ 3 - 8
Server/App/Server.App.csproj

@@ -18,8 +18,8 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\Bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;SERVER</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -27,7 +27,7 @@
     <PlatformTarget>AnyCPU</PlatformTarget>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -66,11 +66,6 @@
       <Name>Server.Model</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="Start.txt">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 0 - 5
Server/App/Start.txt

@@ -1,5 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("9223372036854775805"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("9223372036854775804"), "Host" : "192.168.12.188", "Port" : 20000 }, { "_t" : "OuterConfig", "_id" : NumberLong("9223372036854775803"), "Host" : "192.168.12.188", "Port" : 10000 }], "AppId" : 1, "AppType" : "Manager", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("9223372036854775805"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("9223372036854775804"), "Host" : "192.168.12.188", "Port" : 20001 }, { "_t" : "OuterConfig", "_id" : NumberLong("9223372036854775803"), "Host" : "192.168.12.188", "Port" : 10001 }], "AppId" : 2, "AppType" : "Realm", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("9223372036854775805"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("9223372036854775804"), "Host" : "192.168.12.188", "Port" : 20002 }, { "_t" : "OuterConfig", "_id" : NumberLong("9223372036854775803"), "Host" : "192.168.12.188", "Port" : 10002 }], "AppId" : 3, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("9223372036854775805"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("9223372036854775804"), "Host" : "192.168.12.188", "Port" : 20003 }, { "_t" : "OuterConfig", "_id" : NumberLong("9223372036854775803"), "Host" : "192.168.12.188", "Port" : 10003 }], "AppId" : 4, "AppType" : "Gate", "ServerIP" : "*" }
-{ "_t" : "StartConfig", "_id" : NumberLong("9223372036854775805"), "Type" : "Config", "components" : [{ "_t" : "InnerConfig", "_id" : NumberLong("9223372036854775804"), "Host" : "192.168.12.188", "Port" : 20004 }, { "_t" : "OuterConfig", "_id" : NumberLong("9223372036854775803"), "Host" : "192.168.12.188", "Port" : 10004 }], "AppId" : 5, "AppType" : "Gate", "ServerIP" : "*" }

+ 3 - 3
Server/Base/Server.Base.csproj

@@ -16,15 +16,15 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\Bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;SERVER</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 0 - 5
Server/Build.sh

@@ -1,5 +0,0 @@
-#!/bin/bash
-xbuild ./Server.sln
-cd Bin/Debug/
-cmake ../..
-make

+ 1 - 1
Server/Controller/Message/M2A_ReloadHandler.cs

@@ -5,7 +5,7 @@ using Object = Base.Object;
 
 namespace Controller
 {
-	[MessageHandler(AppType.Manager, AppType.Realm, AppType.Gate)]
+	[MessageHandler(AppType.AllServer)]
 	public class M2A_ReloadHandler : AMRpcEvent<M2A_Reload, A2M_Reload>
 	{
 		protected override void Run(Session session, M2A_Reload message, Action<A2M_Reload> reply)

+ 2 - 2
Server/Controller/Server.Controller.csproj

@@ -16,7 +16,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\Bin\Debug\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE;DEBUG;SERVER</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -24,7 +24,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 4 - 4
Server/Model/Component/AppManagerComponent.cs

@@ -24,6 +24,7 @@ namespace Model
 		{
 			string[] ips = NetHelper.GetAddressIPs();
 			StartConfig[] startConfigs = Game.Scene.GetComponent<StartConfigComponent>().GetAll();
+			string configFile = Game.Scene.GetComponent<StartConfigComponent>().Options.Config;
 			foreach (StartConfig startConfig in startConfigs)
 			{
 				if (!ips.Contains(startConfig.ServerIP) && startConfig.ServerIP != "*")
@@ -31,18 +32,17 @@ namespace Model
 					continue;
 				}
 
-				if (startConfig.AppType == AppType.Manager)
+				if (startConfig.AppType.Is(AppType.Manager))
 				{
 					continue;
 				}
 
-
 #if __MonoCS__
 				const string exe = @"mono";
-				string arguments = $"--debug App.exe --appId={startConfig.AppId} --appType={startConfig.AppType}";
+				string arguments = $"--debug App.exe --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
 #else
 				const string exe = @"App.exe";
-				string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType}";
+				string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
 #endif
 
 				Log.Info($"{exe} {arguments}");

+ 1 - 1
Server/Model/Component/RealmGateAddressComponent.cs

@@ -21,7 +21,7 @@ namespace Model
 			StartConfig[] startConfigs = this.GetComponent<StartConfigComponent>().GetAll();
 			foreach (StartConfig config in startConfigs)
 			{
-				if (config.AppType != AppType.Gate)
+				if (!config.AppType.Is(AppType.Gate))
 				{
 					continue;
 				}

+ 9 - 8
Server/Model/Component/StartConfigComponent.cs

@@ -21,11 +21,18 @@ namespace Model
 
 		private readonly Dictionary<int, StartConfig> configDict = new Dictionary<int, StartConfig>();
 
+		public Options Options = new Options();
+
 		public StartConfig MyConfig { get; private set; }
 
 		public void Awake(string[] args)
 		{
-			string[] ss = File.ReadAllText("./Start.txt").Split('\n');
+			if (!Parser.Default.ParseArguments(args, this.Options))
+			{
+				throw new Exception($"命令行格式错误!");
+			}
+			
+			string[] ss = File.ReadAllText(this.Options.Config).Split('\n');
 			foreach (string s in ss)
 			{
 				string s2 = s.Trim();
@@ -45,13 +52,7 @@ namespace Model
 				}
 			}
 
-			Options options = new Options();
-			if (!Parser.Default.ParseArguments(args, options))
-			{
-				throw new Exception($"命令行格式错误!");
-			}
-
-			this.MyConfig = this.Get(options.AppId);
+			this.MyConfig = this.Get(this.Options.AppId);
 		}
 
 		public StartConfig Get(int id)

+ 2 - 2
Server/Model/Server.Model.csproj

@@ -16,7 +16,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\Bin\Debug\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE;DEBUG;SERVER</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -24,7 +24,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 0 - 9
Server/Run.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-xbuild ./Server.sln
-cd Bin/Debug/
-cmake ../..
-make
-
-ps -ef | grep App.exe | awk '{print $2}' | xargs kill -9
-mono --debug App.exe --appId=1 --appType=Manager

+ 16 - 0
Server/Server.sln

@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ThirdParty", "ThirdParty",
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server.App", "App\Server.App.csproj", "{3F8DC04C-9E05-403F-B6A5-36293EB99937}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENet", "ThirdParty\ENet\ENet.vcxproj", "{C9992B7C-313E-4C9F-A954-640D01EDFB58}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -71,8 +73,22 @@ Global
 		{3F8DC04C-9E05-403F-B6A5-36293EB99937}.Release|x64.Build.0 = Release|Any CPU
 		{3F8DC04C-9E05-403F-B6A5-36293EB99937}.Release|x86.ActiveCfg = Release|Any CPU
 		{3F8DC04C-9E05-403F-B6A5-36293EB99937}.Release|x86.Build.0 = Release|Any CPU
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|Any CPU.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x64.ActiveCfg = Debug|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x64.Build.0 = Debug|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.ActiveCfg = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Debug|x86.Build.0 = Debug|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|Any CPU.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x64.ActiveCfg = Release|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x64.Build.0 = Release|x64
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.ActiveCfg = Release|Win32
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {01CCAD69-09B1-42F9-8A39-489268BEE18D}
+	EndGlobalSection
 EndGlobal

+ 6 - 5
Server/ThirdParty/ENet/ENet.vcxproj

@@ -24,6 +24,7 @@
     <Keyword>ManagedCProj</Keyword>
     <RootNamespace>ENet</RootNamespace>
     <ProjectName>ENet</ProjectName>
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -36,7 +37,7 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v140_xp</PlatformToolset>
+    <PlatformToolset>v140</PlatformToolset>
     <CLRSupport>false</CLRSupport>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
@@ -73,8 +74,8 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(SolutionDir)\Platform\;$(IncludePath)</IncludePath>
-    <OutDir>$(SolutionDir)\Bin\$(Configuration)\</OutDir>
-    <IntDir>$(SolutionDir)\Temp\$(Configuration)\</IntDir>
+    <OutDir>$(SolutionDir)..\Bin\</OutDir>
+    <IntDir>$(SolutionDir)..\Temp\</IntDir>
     <TargetExt>.dll</TargetExt>
     <TargetName>$(ProjectName)</TargetName>
   </PropertyGroup>
@@ -83,8 +84,8 @@
     <TargetName>$(ProjectName)</TargetName>
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(SolutionDir)\Platform\;$(IncludePath)</IncludePath>
-    <OutDir>$(SolutionDir)\Bin\$(Configuration)\</OutDir>
-    <IntDir>$(SolutionDir)\Temp\$(Configuration)\</IntDir>
+    <OutDir>$(SolutionDir)..\Bin\</OutDir>
+    <IntDir>$(SolutionDir)..\Temp\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>

+ 2 - 2
Server/Start.sh → Start.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
 
-cd Bin/Debug/
+cd Bin
 ps -ef | grep App.exe | awk '{print $2}' | xargs kill -9
-mono --debug App.exe --appId=1 --appType=Manager
+mono --debug App.exe --appId=1 --appType=Manager --config=../$1

+ 0 - 0
Config/.emacs → Tools/Config/.emacs


+ 0 - 0
Config/.gitconfig → Tools/Config/.gitconfig


+ 0 - 0
Config/.screenrc → Tools/Config/.screenrc


+ 0 - 0
Config/Egametang.ffs_batch → Tools/Config/Egametang.ffs_batch


+ 0 - 0
Config/Egametang.ffs_gui → Tools/Config/Egametang.ffs_gui


+ 0 - 0
Config/Unity.sln.DotSettings → Tools/Config/Unity.sln.DotSettings


+ 0 - 0
Config/VS.vssettings → Tools/Config/VS.vssettings


+ 0 - 0
Config/eclipse.epf → Tools/Config/eclipse.epf


+ 2 - 2
Config/Rsync/exclude.txt → Tools/cwRsync/Config/exclude.txt

@@ -1,9 +1,9 @@
 .git/
 Log/
 Tools/
-Server/Bin/
+Bin/
 Server/packages/
-Server/Temp/
+Temp/
 Server/Server.sdf
 Unity/Library/
 Unity/Temp/

+ 0 - 0
Config/Rsync/rsync.secrets → Tools/cwRsync/Config/rsync.secrets


+ 1 - 0
Tools/cwRsync/Config/rsyncConfig.txt

@@ -0,0 +1 @@
+{ "_t" : "RsyncConfig", "Host" : "192.168.12.188", "Account" : "tanghai", "Password" : "1234567890", "RelativePath" : "Source/Egametang", "Exclude" : [".git/", "Log/", "Tools/", "Bin/", "Server/packages/", "Temp/", "Server/Server.sdf", "Unity/Library/", "Unity/Temp/", "*/obj"] }

+ 0 - 0
Config/Rsync/rsyncd.conf → Tools/cwRsync/Config/rsyncd.conf


+ 0 - 0
Config/Rsync/rsyncd.secrets → Tools/cwRsync/Config/rsyncd.secrets


+ 6 - 6
Unity/Assets/Editor/RsyncEditor/RsyncEditor.cs

@@ -8,7 +8,7 @@ namespace MyEditor
 {
 	public class RsyncEditor : EditorWindow
 	{
-		private const string ConfigFile = @"..\Config\Rsync\rsyncConfig.txt";
+		private const string ConfigFile = @"..\Tools\cwRsync\Config\rsyncConfig.txt";
 		private RsyncConfig rsyncConfig;
 		private bool isFold = true;
 
@@ -61,7 +61,7 @@ namespace MyEditor
 			if (GUILayout.Button("保存"))
 			{
 				File.WriteAllText(ConfigFile, MongoHelper.ToJson(this.rsyncConfig));
-				using (StreamWriter sw = new StreamWriter(new FileStream(@"..\Config\Rsync\rsync.secrets", FileMode.Create)))
+				using (StreamWriter sw = new StreamWriter(new FileStream(@"..\Tools\cwRsync\Config\exclude.txt", FileMode.Create)))
 				{
 					foreach (string s in this.rsyncConfig.Exclude)
 					{
@@ -69,8 +69,8 @@ namespace MyEditor
 					}
 				}
 
-				File.WriteAllText($@"..\Config\Rsync\rsync.secrets", this.rsyncConfig.Password);
-				File.WriteAllText($@"..\Config\Rsync\rsyncd.secrets", $"{this.rsyncConfig.Account}:{this.rsyncConfig.Password}");
+				File.WriteAllText($@"..\Tools\cwRsync\Config\rsync.secrets", this.rsyncConfig.Password);
+				File.WriteAllText($@"..\Tools\cwRsync\Config\rsyncd.secrets", $"{this.rsyncConfig.Account}:{this.rsyncConfig.Password}");
 
 				string rsyncdConf =
 					"uid = root\n" +
@@ -85,12 +85,12 @@ namespace MyEditor
 					$"auth users = {this.rsyncConfig.Account}\n" +
 					"secrets file = /etc/rsyncd.secrets\n" +
 					"list = yes";
-				File.WriteAllText($@"..\Config\Rsync\rsyncd.conf", rsyncdConf);
+				File.WriteAllText($@"..\Tools\cwRsync\Config\rsyncd.conf", rsyncdConf);
 			}
 
 			if (GUILayout.Button("同步"))
 			{
-				string arguments = $"-vzrtopg --password-file=./Config/Rsync/rsync.secrets --exclude-from=./Config/Rsync/exclude.txt --delete ./ {this.rsyncConfig.Account}@{this.rsyncConfig.Host}::Upload/{this.rsyncConfig.RelativePath} --chmod=ugo=rwX";
+				string arguments = $"-vzrtopg --password-file=./Tools/cwRsync/Config/rsync.secrets --exclude-from=./Tools/cwRsync/Config/exclude.txt --delete ./ {this.rsyncConfig.Account}@{this.rsyncConfig.Host}::Upload/{this.rsyncConfig.RelativePath} --chmod=ugo=rwX";
 				ProcessStartInfo startInfo = new ProcessStartInfo();
 				startInfo.FileName = @".\Tools\cwRsync\rsync.exe";
 				startInfo.Arguments = arguments;

+ 75 - 15
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -2,9 +2,9 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
+using System.Linq;
 using Base;
 using Model;
-using MongoDB.Bson.Serialization;
 using UnityEditor;
 using UnityEngine;
 
@@ -12,14 +12,22 @@ namespace MyEditor
 {
 	public class ServerCommandLineEditor : EditorWindow
 	{
-		private const string Path = @"..\Server\App\Start.txt";
+		private const string ConfigDir = @"..\Config\StartConfig\";
+
+		private List<string> files;
+
+		private int selectedIndex;
+
+		private string fileName;
+
+		private string addFileName;
 
 		private int copyNum = 1;
 
 		private AppType AppType = AppType.Manager;
 
 		private readonly List<StartConfig> startConfigs = new List<StartConfig>();
-	
+
 		[MenuItem("Tools/命令行配置")]
 		private static void ShowWindow()
 		{
@@ -28,7 +36,27 @@ namespace MyEditor
 
 		private void OnEnable()
 		{
-			if (!File.Exists(Path))
+			this.files = this.GetConfigFiles();
+			if (this.files.Count > 0)
+			{
+				this.fileName = this.files[this.selectedIndex];
+				this.LoadConfig();
+			}
+		}
+
+		private List<string> GetConfigFiles()
+		{
+			List<string> fs = Directory.GetFiles(ConfigDir).ToList();
+			DirectoryInfo directoryInfo = new DirectoryInfo(ConfigDir);
+			FileInfo[] fileInfo = directoryInfo.GetFiles();
+			fs = fileInfo.Select(x => x.Name).ToList();
+			return fs;
+		}
+
+		private void LoadConfig()
+		{
+			string filePath = this.GetFilePath();
+			if (!File.Exists(filePath))
 			{
 				return;
 			}
@@ -36,7 +64,8 @@ namespace MyEditor
 			string s2 = "";
 			try
 			{
-				string[] ss = File.ReadAllText(Path).Split('\n');
+				this.startConfigs.Clear();
+				string[] ss = File.ReadAllText(filePath).Split('\n');
 				foreach (string s in ss)
 				{
 					s2 = s.Trim();
@@ -55,8 +84,38 @@ namespace MyEditor
 			}
 		}
 
+		private string GetFilePath()
+		{
+			return Path.Combine(ConfigDir, this.fileName);
+		}
+
 		private void OnGUI()
 		{
+			GUILayout.BeginHorizontal();
+			string[] filesArray = this.files.ToArray();
+			this.selectedIndex = EditorGUILayout.Popup(this.selectedIndex, filesArray);
+
+			string lastFile = this.fileName;
+			this.fileName = this.files[this.selectedIndex];
+
+			if (this.fileName != lastFile)
+			{
+				this.LoadConfig();
+			}
+			
+			this.addFileName = EditorGUILayout.TextField("文件名", this.addFileName);
+
+			if (GUILayout.Button("添加配置文件"))
+			{
+				this.fileName = this.addFileName;
+				this.addFileName = "";
+				File.WriteAllText(this.GetFilePath(), "");
+				this.files = this.GetConfigFiles();
+				this.selectedIndex = this.files.IndexOf(this.fileName);
+			}
+			GUILayout.EndHorizontal();
+
+			GUILayout.Label("配置内容:");
 			for (int i = 0; i < this.startConfigs.Count; ++i)
 			{
 				StartConfig startConfig = this.startConfigs[i];
@@ -105,23 +164,22 @@ namespace MyEditor
 				GUILayout.EndHorizontal();
 			}
 
-			GUILayout.BeginHorizontal();
-			this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);
-			GUILayout.EndHorizontal();
+			GUILayout.Label("");
 
 			GUILayout.BeginHorizontal();
+			this.copyNum = EditorGUILayout.IntField("复制数量: ", this.copyNum);
 
 			GUILayout.Label($"添加的AppType:");
 			this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);
 
-			if (GUILayout.Button("添加"))
+			if (GUILayout.Button("添加一行配置"))
 			{
 				StartConfig newStartConfig = new StartConfig();
 
 				newStartConfig.AppType = this.AppType;
 				newStartConfig.AddComponent<InnerConfig>();
 
-				if (this.AppType == AppType.Gate || this.AppType == AppType.Realm || this.AppType == AppType.Manager)
+				if (this.AppType.Is(AppType.Gate) || this.AppType.Is(AppType.Realm) || this.AppType.Is(AppType.Manager))
 				{
 					newStartConfig.AddComponent<OuterConfig>();
 				}
@@ -130,11 +188,13 @@ namespace MyEditor
 			}
 			GUILayout.EndHorizontal();
 
+
 			GUILayout.BeginHorizontal();
 
 			if (GUILayout.Button("保存"))
 			{
-				using (StreamWriter sw = new StreamWriter(new FileStream(Path, FileMode.Create)))
+				string path = this.GetFilePath();
+				using (StreamWriter sw = new StreamWriter(new FileStream(path, FileMode.Create)))
 				{
 					foreach (StartConfig startConfig in this.startConfigs)
 					{
@@ -149,7 +209,7 @@ namespace MyEditor
 				StartConfig startConfig = null;
 				foreach (StartConfig config in this.startConfigs)
 				{
-					if (config.AppType == Model.AppType.Manager)
+					if (config.AppType.Is(AppType.Manager))
 					{
 						startConfig = config;
 					}
@@ -160,13 +220,13 @@ namespace MyEditor
 					Log.Error("没有配置Manager!");
 					return;
 				}
-				
-				string arguments = $"--id={startConfig.AppId} --appType={startConfig.AppType}";
+
+				string arguments = $"--appId={startConfig.AppId} --appType={startConfig.AppType} --config=../Config/StartConfig/{this.fileName}";
 
 				ProcessStartInfo info = new ProcessStartInfo(@"App.exe", arguments)
 				{
 					UseShellExecute = true,
-					WorkingDirectory = @"..\Server\Bin\Debug"
+					WorkingDirectory = @"..\Bin\"
 				};
 				Process.Start(info);
 			}

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

@@ -43,9 +43,7 @@ namespace Base
 			{
 				return;
 			}
-			
 			base.Dispose();
-
 			this.socket.Dispose();
 		}
 

+ 2 - 1
Unity/Assets/Plugins/Base/Object/Entity.cs

@@ -9,7 +9,8 @@ namespace Base
 	{
 		public string Type { get; set; }
 
-		[BsonElement, BsonIgnoreIfNull]
+		[BsonElement]
+		[BsonIgnoreIfNull]
 		private HashSet<Component> components = new HashSet<Component>();
 
 		[BsonIgnore]

+ 7 - 0
Unity/Assets/Scripts/Component/NetworkComponent.cs

@@ -63,6 +63,12 @@ namespace Model
 
 		private void Add(Session session)
 		{
+			Session s;
+			if (this.adressSessions.TryGetValue(session.RemoteAddress, out s))
+			{
+				this.Remove(s.Id);
+				Log.Warning($"session 地址冲突, 可能是客户端断开, 服务器还没检测到!: {session.RemoteAddress}");
+			}
 			this.sessions.Add(session.Id, session);
 			this.adressSessions.Add(session.RemoteAddress, session);
 		}
@@ -76,6 +82,7 @@ namespace Model
 			}
 			this.sessions.Remove(id);
 			this.adressSessions.Remove(session.RemoteAddress);
+			session.Dispose();
 		}
 
 		public Session Get(long id)

+ 18 - 6
Unity/Assets/Scripts/Message/AppType.cs

@@ -7,23 +7,35 @@ namespace Model
 	{
 		
 	}
-
+	
+	[Flags]
 	public enum AppType
 	{
+		Manager = 1,
+		Realm = 2,
+		Gate = 4,
+		// 7
+		AllServer = Manager | Realm | Gate,
+
 		Client,
 		Robot,
-		
-		Manager,
-		Realm,
-		Gate,
 	}
 
 	public static class AppTypeHelper
 	{
 		public static List<AppType> GetServerTypes()
 		{
-			List<AppType> appTypes = new List<AppType>() { AppType.Manager, AppType.Realm, AppType.Gate };
+			List<AppType> appTypes = new List<AppType> { AppType.Manager, AppType.Realm, AppType.Gate };
 			return appTypes;
 		}
+
+		public static bool Is(this AppType a, AppType b)
+		{
+			if ((a & b) != 0)
+			{
+				return true;
+			}
+			return false;
+		}
 	}
 }

+ 4 - 7
Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs

@@ -8,19 +8,16 @@ namespace Model
 	/// </summary>
 	public class MessageHandlerAttribute : Attribute
 	{
-		private HashSet<AppType> AppTypes { get; } = new HashSet<AppType>();
+		private readonly AppType type;
 
-		public MessageHandlerAttribute(params AppType[] appTypes)
+		public MessageHandlerAttribute(AppType appType)
 		{
-			foreach (AppType appType in appTypes)
-			{
-				this.AppTypes.Add(appType);
-			}
+			this.type = appType;
 		}
 
 		public bool Contains(AppType appType)
 		{
-			return this.AppTypes.Contains(appType);
+			return this.type.Is(appType);
 		}
 	}
 }

+ 5 - 13
Unity/Assets/Scripts/Other/Options.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Text;
 using Base;
 using MongoDB.Bson.Serialization.Attributes;
 #if SERVER
@@ -11,26 +10,19 @@ namespace Model
 	public class Options: ICloneable
 	{
 #if SERVER
-		[Option("appId", Required = true, HelpText = "Id.")]
+		[Option("appId", Required = true)]
 #endif
 		public int AppId { get; set; }
 
 #if SERVER
-		[Option("appType", Required = true, HelpText = "AppType: realm gate")]
+		[Option("appType", Required = true)]
 #endif
-		public string AppType { get; set; }
+		public AppType AppType { get; set; }
 
 #if SERVER
-		[HelpOption]
+		[Option("config", Required = false, DefaultValue = "Start.txt")]
 #endif
-		public string GetUsage()
-		{
-			// this without using CommandLine.Text
-			StringBuilder usage = new StringBuilder();
-			usage.AppendLine("Quickstart Application 1.0");
-			usage.AppendLine("Read user manual for usage instructions...");
-			return usage.ToString();
-		}
+		public string Config { get; set; }
 
 		public object Clone()
 		{

+ 6 - 4
Unity/Assets/Scripts/Other/StartConfig.cs

@@ -1,14 +1,16 @@
-using System;
-using Base;
+using Base;
+using MongoDB.Bson;
+using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {
 	public class StartConfig: Entity
 	{
 		public int AppId { get; set; }
-
+		
+		[BsonRepresentation(BsonType.String)]
 		public AppType AppType { get; set; }
-
+		
 		public string ServerIP { get; set; }
 
 		public StartConfig(): base(EntityType.Config)

+ 3 - 1
Unity/Unity.sln

@@ -1,6 +1,8 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2015
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.CSharp.Plugins", "Unity.CSharp.Plugins.csproj", "{1AA60596-6964-87F6-2427-6CA85BBAF27D}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.CSharp", "Unity.CSharp.csproj", "{4123F183-8F61-27AE-EA27-294DDE0CC7EB}"