Parcourir la source

AppType EventIdType 等改成枚举类型

tanghai il y a 9 ans
Parent
commit
d865b20e25
37 fichiers modifiés avec 123 ajouts et 188 suppressions
  1. 2 2
      Server/App/Program.cs
  2. 0 18
      Server/Base/Server.Base.csproj
  3. 1 1
      Server/Model/Component/LogToClientComponent.cs
  4. 1 1
      Server/Model/Component/RealmGateAddressComponent.cs
  5. 18 3
      Server/Model/Server.Model.csproj
  6. 4 4
      Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs
  7. 6 7
      Unity/Assets/Editor/ServerManagerEditor/ServerManagerEditor.cs
  8. 0 9
      Unity/Assets/Plugins/Base/Event.meta
  9. 0 10
      Unity/Assets/Plugins/Base/Event/EnvBaseKey.cs
  10. 0 12
      Unity/Assets/Plugins/Base/Event/EnvBaseKey.cs.meta
  11. 0 9
      Unity/Assets/Plugins/Base/Event/EventBaseType.cs
  12. 0 12
      Unity/Assets/Plugins/Base/Event/EventBaseType.cs.meta
  13. 1 7
      Unity/Assets/Plugins/Base/Object/Component.cs
  14. 0 5
      Unity/Assets/Plugins/Base/Object/Entity.cs
  15. 4 0
      Unity/Assets/Plugins/Base/Object/Object.cs
  16. 9 9
      Unity/Assets/Scripts/Component/EventComponent.cs
  17. 10 5
      Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
  18. 1 1
      Unity/Assets/Scripts/Entity/Game.cs
  19. 3 3
      Unity/Assets/Scripts/Event/AEventAttribute.cs
  20. 2 2
      Unity/Assets/Scripts/Event/AEventAttribute.cs.meta
  21. 12 12
      Unity/Assets/Scripts/Event/Env.cs
  22. 2 2
      Unity/Assets/Scripts/Event/Env.cs.meta
  23. 2 2
      Unity/Assets/Scripts/Event/EnvKey.cs
  24. 2 2
      Unity/Assets/Scripts/Event/EventAttribute.cs
  25. 2 2
      Unity/Assets/Scripts/Event/EventAttribute.cs.meta
  26. 2 2
      Unity/Assets/Scripts/Event/EventIdType.cs
  27. 1 1
      Unity/Assets/Scripts/Event/IEvent.cs
  28. 2 2
      Unity/Assets/Scripts/Event/IEvent.cs.meta
  29. 24 7
      Unity/Assets/Scripts/Message/AppType.cs
  30. 2 2
      Unity/Assets/Scripts/Message/Message.cs
  31. 4 4
      Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs
  32. 0 9
      Unity/Assets/Scripts/Other/ServerType.cs
  33. 0 12
      Unity/Assets/Scripts/Other/ServerType.cs.meta
  34. 1 1
      Unity/Assets/Scripts/Other/StartConfig.cs
  35. 1 1
      Unity/Controller/Event/InitSceneStartEvent_InitGame.cs
  36. 0 6
      Unity/Unity.CSharp.Plugins.csproj
  37. 4 1
      Unity/Unity.CSharp.csproj

+ 2 - 2
Server/App/Program.cs

@@ -22,7 +22,7 @@ namespace App
 
 				IdGenerater.AppId = startConfig.AppId;
 
-				LogManager.Configuration.Variables["appType"] = startConfig.AppType;
+				LogManager.Configuration.Variables["appType"] = startConfig.AppType.ToString();
 				LogManager.Configuration.Variables["appId"] = startConfig.AppId.ToString();
 
 				Log.Info("server start........................");
@@ -32,7 +32,7 @@ namespace App
 
 				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
 				Game.Scene.AddComponent<NetInnerComponent, string, int>(innerConfig.Host, innerConfig.Port);
-				Game.Scene.AddComponent<MessageDispatherComponent, string>(startConfig.AppType);
+				Game.Scene.AddComponent<MessageDispatherComponent, AppType>(startConfig.AppType);
 
 				// 根据不同的AppType添加不同的组件
 				OuterConfig outerConfig = startConfig.GetComponent<OuterConfig>();

+ 0 - 18
Server/Base/Server.Base.csproj

@@ -62,24 +62,6 @@
     <Compile Include="..\..\Unity\Assets\Plugins\Base\DoubleMap.cs">
       <Link>DoubleMap.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\AEventAttribute.cs">
-      <Link>Event\AEventAttribute.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\Env.cs">
-      <Link>Event\Env.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\EnvBaseKey.cs">
-      <Link>Event\EnvBaseKey.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\EventAttribute.cs">
-      <Link>Event\EventAttribute.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\EventBaseType.cs">
-      <Link>Event\EventBaseType.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Plugins\Base\Event\IEvent.cs">
-      <Link>Event\IEvent.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Plugins\Base\Helper\ArrayHelper.cs">
       <Link>Helper\ArrayHelper.cs</Link>
     </Compile>

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

@@ -13,7 +13,7 @@ namespace Model
 
 	public class LogToClientComponent : Component
 	{
-		private string appType;
+		private AppType appType;
 		private int appId;
 
 		public void Awake()

+ 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 != "Gate")
+				if (config.AppType != AppType.Gate)
 				{
 					continue;
 				}

+ 18 - 3
Server/Model/Server.Model.csproj

@@ -71,6 +71,24 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Session.cs">
       <Link>Entity\Session.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\AEventAttribute.cs">
+      <Link>Event\AEventAttribute.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\Env.cs">
+      <Link>Event\Env.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\EnvKey.cs">
+      <Link>Event\EnvKey.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\EventAttribute.cs">
+      <Link>Event\EventAttribute.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\EventIdType.cs">
+      <Link>Event\EventIdType.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Event\IEvent.cs">
+      <Link>Event\IEvent.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Message\AMessage.cs">
       <Link>Message\AMessage.cs</Link>
     </Compile>
@@ -110,9 +128,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Other\Options.cs">
       <Link>Other\Options.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Other\ServerType.cs">
-      <Link>Other\ServerType.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\StartConfig.cs">
       <Link>Other\StartConfig.cs</Link>
     </Compile>

+ 4 - 4
Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs

@@ -16,7 +16,7 @@ namespace MyEditor
 
 		private int copyNum = 1;
 
-		private string AppType = Model.AppType.Manager;
+		private AppType AppType = AppType.Manager;
 
 		private readonly List<StartConfig> startConfigs = new List<StartConfig>();
 	
@@ -66,7 +66,7 @@ namespace MyEditor
 				GUILayout.Label($"服务器IP:");
 				startConfig.ServerIP = EditorGUILayout.TextField(startConfig.ServerIP);
 				GUILayout.Label($"AppType:");
-				startConfig.AppType = EditorGUILayout.TextField(startConfig.AppType);
+				startConfig.AppType = (AppType)EditorGUILayout.EnumPopup(startConfig.AppType);
 
 				InnerConfig innerConfig = startConfig.GetComponent<InnerConfig>();
 				if (innerConfig != null)
@@ -112,7 +112,7 @@ namespace MyEditor
 			GUILayout.BeginHorizontal();
 
 			GUILayout.Label($"添加的AppType:");
-			this.AppType = EditorGUILayout.TextField(this.AppType);
+			this.AppType = (AppType)EditorGUILayout.EnumPopup(this.AppType);
 
 			if (GUILayout.Button("添加"))
 			{
@@ -121,7 +121,7 @@ namespace MyEditor
 				newStartConfig.AppType = this.AppType;
 				newStartConfig.AddComponent<InnerConfig>();
 
-				if (this.AppType == Model.AppType.Gate || this.AppType == Model.AppType.Realm || this.AppType == Model.AppType.Manager)
+				if (this.AppType == AppType.Gate || this.AppType == AppType.Realm || this.AppType == AppType.Manager)
 				{
 					newStartConfig.AddComponent<OuterConfig>();
 				}

+ 6 - 7
Unity/Assets/Editor/ServerManagerEditor/ServerManagerEditor.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using Base;
 using Model;
 using UnityEditor;
@@ -13,7 +12,7 @@ namespace MyEditor
 
 		private bool isAll;
 
-		private readonly string[] serverTypes = Enum.GetNames(typeof(ServerType));
+		private readonly List<AppType> serverTypes = AppTypeHelper.GetServerTypes();
 		private bool[] isCheck;
 
 		[MenuItem("Tools/服务器管理")]
@@ -24,7 +23,7 @@ namespace MyEditor
 
 		private void OnEnable()
 		{
-			this.isCheck = new bool[this.serverTypes.Length];
+			this.isCheck = new bool[this.serverTypes.Count];
 		}
 
 		private void OnGUI()
@@ -36,7 +35,7 @@ namespace MyEditor
 			}
 
 			
-			List<string> selected = new List<string>();
+			List<AppType> selected = new List<AppType>();
 			this.isAll = GUILayout.Toggle(this.isAll, "All");
 			if (this.isAll)
 			{
@@ -46,9 +45,9 @@ namespace MyEditor
 				}
 			}
 
-			for (int i = 0; i < this.serverTypes.Length; ++i)
+			for (int i = 0; i < this.serverTypes.Count; ++i)
 			{
-				this.isCheck[i] = GUILayout.Toggle(this.isCheck[i], this.serverTypes[i]);
+				this.isCheck[i] = GUILayout.Toggle(this.isCheck[i], this.serverTypes[i].ToString());
 				if (!this.isCheck[i])
 				{
 					this.isAll = false;

+ 0 - 9
Unity/Assets/Plugins/Base/Event.meta

@@ -1,9 +0,0 @@
-fileFormatVersion: 2
-guid: 3bd13b1e460a3684580d79ebf98ab1ee
-folderAsset: yes
-timeCreated: 1476427109
-licenseType: Pro
-DefaultImporter:
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 10
Unity/Assets/Plugins/Base/Event/EnvBaseKey.cs

@@ -1,10 +0,0 @@
-namespace Base
-{
-	/// <summary>
-	/// 一般使用事件名+变量名
-	/// </summary>
-	public static class EnvBaseKey
-	{
-		public const string ChannelError = "ChannelError";
-	}
-}

+ 0 - 12
Unity/Assets/Plugins/Base/Event/EnvBaseKey.cs.meta

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

+ 0 - 9
Unity/Assets/Plugins/Base/Event/EventBaseType.cs

@@ -1,9 +0,0 @@
-namespace Base
-{
-    public static class EventBaseType
-	{
-		public const int LogError = 1;
-		public const int NetworkChannelError = 2;
-		public const int InitSceneStart = 10;
-    }
-}

+ 0 - 12
Unity/Assets/Plugins/Base/Event/EventBaseType.cs.meta

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

+ 1 - 7
Unity/Assets/Plugins/Base/Object/Component.cs

@@ -17,12 +17,10 @@ namespace Base
 
 		protected Component()
 		{
-			ObjectManager.Add(this);
 		}
 
 		protected Component(long id): base(id)
 		{
-			ObjectManager.Add(this);
 		}
 
 		protected T GetComponent<T>() where T: Component
@@ -36,12 +34,8 @@ namespace Base
 			{
 				return;
 			}
-
-			long id = this.Id;
-
+			
 			base.Dispose();
-
-			ObjectManager.Remove(id);
 		}
 	}
 }

+ 0 - 5
Unity/Assets/Plugins/Base/Object/Entity.cs

@@ -18,13 +18,11 @@ namespace Base
 		protected Entity(string entityType)
 		{
 			this.Type = entityType;
-			ObjectManager.Add(this);
 		}
 
 		protected Entity(long id, string entityType) : base(id)
 		{
 			this.Type = entityType;
-			ObjectManager.Add(this);
 		}
 		
 		public override void Dispose()
@@ -33,8 +31,6 @@ namespace Base
 			{
 				return;
 			}
-
-			long id = this.Id;
 			
 			base.Dispose();
 
@@ -49,7 +45,6 @@ namespace Base
 					Log.Error(e.ToString());
 				}
 			}
-			ObjectManager.Remove(id);
 		}
 
 		public K AddComponent<K>() where K : Component, new()

+ 4 - 0
Unity/Assets/Plugins/Base/Object/Object.cs

@@ -15,11 +15,13 @@ namespace Base
 		protected Object()
 		{
 			Id = IdGenerater.GenerateId();
+			ObjectManager.Add(this);
 		}
 
 		protected Object(long id)
 		{
 			this.Id = id;
+			ObjectManager.Add(this);
 		}
 
 		public bool IsDisposed()
@@ -34,6 +36,8 @@ namespace Base
 				return;
 			}
 
+			ObjectManager.Remove(this.Id);
+
 			this.Id = 0;
 		}
 

+ 9 - 9
Unity/Assets/Scripts/Component/EventComponent.cs

@@ -25,11 +25,11 @@ namespace Model
 	/// </summary>
 	public class EventComponent: Component
 	{
-		private Dictionary<int, List<object>> allEvents;
+		private Dictionary<EventIdType, List<object>> allEvents;
 
 		public void Load()
 		{
-			this.allEvents = new Dictionary<int, List<object>>();
+			this.allEvents = new Dictionary<EventIdType, List<object>>();
 			Assembly[] assemblies = Object.ObjectManager.GetAssemblies();
 			foreach (Assembly assembly in assemblies)
 			{
@@ -53,7 +53,7 @@ namespace Model
 			}
 		}
 
-		public void Run(int type)
+		public void Run(EventIdType type)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -79,7 +79,7 @@ namespace Model
 			}
 		}
 
-		public void Run<A>(int type, A a)
+		public void Run<A>(EventIdType type, A a)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -105,7 +105,7 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B>(int type, A a, B b)
+		public void Run<A, B>(EventIdType type, A a, B b)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -131,7 +131,7 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B, C>(int type, A a, B b, C c)
+		public void Run<A, B, C>(EventIdType type, A a, B b, C c)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -157,7 +157,7 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B, C, D>(int type, A a, B b, C c, D d)
+		public void Run<A, B, C, D>(EventIdType type, A a, B b, C c, D d)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -183,7 +183,7 @@ namespace Model
 			}
 		}
 
-		public void Run<A, B, C, D, E>(int type, A a, B b, C c, D d, E e)
+		public void Run<A, B, C, D, E>(EventIdType type, A a, B b, C c, D d, E e)
 		{
 			List<object> iEvents = null;
 			if (!this.allEvents.TryGetValue(type, out iEvents))
@@ -209,7 +209,7 @@ namespace Model
 				}
 			}
 		}
-        public void Run<A, B, C, D, E,F>(int type, A a, B b, C c, D d, E e,F f)
+        public void Run<A, B, C, D, E,F>(EventIdType type, A a, B b, C c, D d, E e,F f)
         {
             List<object> iEvents = null;
             if (!this.allEvents.TryGetValue(type, out iEvents))

+ 10 - 5
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs

@@ -7,14 +7,14 @@ using Object = Base.Object;
 namespace Model
 {
 	[ObjectEvent]
-	public class MessageHandlerComponentEvent : ObjectEvent<MessageDispatherComponent>, ILoader, IAwake<string>
+	public class MessageHandlerComponentEvent : ObjectEvent<MessageDispatherComponent>, ILoader, IAwake<AppType>
 	{
 		public void Load()
 		{
 			this.GetValue().Load();
 		}
 
-		public void Awake(string appType)
+		public void Awake(AppType appType)
 		{
 			this.GetValue().Awake(appType);
 		}
@@ -34,12 +34,12 @@ namespace Model
 			public uint RpcId;
 		}
 
-		private string AppType;
+		private AppType AppType;
 		private Dictionary<ushort, List<Action<Session, MessageInfo>>> handlers;
 		private Dictionary<ushort, Action<Session, MessageInfo>> rpcHandlers;
 		private Dictionary<Type, MessageAttribute> messageOpcode { get; set; } = new Dictionary<Type, MessageAttribute>();
 		
-		public void Awake(string appType)
+		public void Awake(AppType appType)
 		{
 			this.AppType = appType;
 			this.Load();
@@ -100,7 +100,12 @@ namespace Model
 
 		public ushort GetOpcode(Type type)
 		{
-			return this.messageOpcode[type].Opcode;
+			MessageAttribute messageAttribute;
+			if (!this.messageOpcode.TryGetValue(type, out messageAttribute))
+			{
+				throw new Exception($"查找Opcode失败: {type.Name}");
+			}
+			return messageAttribute.Opcode;
 		}
 
 		public void RegisterHandler<Message>(ushort opcode, Action<Session, Message> action) where Message: AMessage

+ 1 - 1
Unity/Assets/Scripts/Entity/Game.cs

@@ -2,7 +2,7 @@
 
 namespace Base
 {
-	public sealed class Game
+	public static class Game
 	{
 		private static Scene scene;
 

+ 3 - 3
Unity/Assets/Plugins/Base/Event/AEventAttribute.cs → Unity/Assets/Scripts/Event/AEventAttribute.cs

@@ -1,13 +1,13 @@
 using System;
 
-namespace Base
+namespace Model
 {
 	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
 	public abstract class AEventAttribute: Attribute
 	{
-		public int Type { get; private set; }
+		public EventIdType Type { get; private set; }
 
-        protected AEventAttribute(int type)
+        protected AEventAttribute(EventIdType type)
         {
 			this.Type = type;
 		}

+ 2 - 2
Unity/Assets/Plugins/Base/Event/AEventAttribute.cs.meta → Unity/Assets/Scripts/Event/AEventAttribute.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 6cb036769594f324aba294b491873809
-timeCreated: 1476427109
+guid: 288485f014836824b89d9a901bc5dcca
+timeCreated: 1477377275
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 12 - 12
Unity/Assets/Plugins/Base/Event/Env.cs → Unity/Assets/Scripts/Event/Env.cs

@@ -3,14 +3,14 @@ using System.Collections;
 using System.Collections.Generic;
 using MongoDB.Bson.Serialization.Attributes;
 
-namespace Base
+namespace Model
 {
-	public class Env: Object
+	public class Env
 	{
 		[BsonElement, BsonIgnoreIfNull]
-		private Dictionary<string, object> values = new Dictionary<string, object>();
+		private Dictionary<EnvKey, object> values = new Dictionary<EnvKey, object>();
 
-		public object this[string key]
+		public object this[EnvKey key]
 		{
 			get
 			{
@@ -20,13 +20,13 @@ namespace Base
 			{
 				if (this.values == null)
 				{
-					this.values = new Dictionary<string, object>();
+					this.values = new Dictionary<EnvKey, object>();
 				}
 				this.values[key] = value;
 			}
 		}
 
-		public T Get<T>(string key)
+		public T Get<T>(EnvKey key)
 		{
 			if (this.values == null || !this.values.ContainsKey(key))
 			{
@@ -43,16 +43,16 @@ namespace Base
 			}
 		}
 
-		public void Set(string key, object obj)
+		public void Set(EnvKey key, object obj)
 		{
 			if (this.values == null)
 			{
-				this.values = new Dictionary<string, object>();
+				this.values = new Dictionary<EnvKey, object>();
 			}
 			this.values[key] = obj;
 		}
 
-		public bool ContainKey(string key)
+		public bool ContainKey(EnvKey key)
 		{
 			if (this.values == null)
 			{
@@ -61,7 +61,7 @@ namespace Base
 			return this.values.ContainsKey(key);
 		}
 
-		public void Remove(string key)
+		public void Remove(EnvKey key)
 		{
 			if (this.values == null)
 			{
@@ -74,11 +74,11 @@ namespace Base
 			}
 		}
 
-		public void Add(string key, object value)
+		public void Add(EnvKey key, object value)
 		{
 			if (this.values == null)
 			{
-				this.values = new Dictionary<string, object>();
+				this.values = new Dictionary<EnvKey, object>();
 			}
 			this.values[key] = value;
 		}

+ 2 - 2
Unity/Assets/Plugins/Base/Event/Env.cs.meta → Unity/Assets/Scripts/Event/Env.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 75e0372bd6348034982793f1f89c8638
-timeCreated: 1476427109
+guid: 414e43d5bdd3d75458b86b1cf07ad175
+timeCreated: 1477377275
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 2 - 2
Unity/Assets/Scripts/Event/EnvKey.cs

@@ -3,8 +3,8 @@
 	/// <summary>
 	/// 一般使用事件名+变量名
 	/// </summary>
-	public static class EnvKey
+	public enum EnvKey
 	{
-		public const string ChannelError = "ChannelError";
+		ChannelError,
 	}
 }

+ 2 - 2
Unity/Assets/Plugins/Base/Event/EventAttribute.cs → Unity/Assets/Scripts/Event/EventAttribute.cs

@@ -1,8 +1,8 @@
-namespace Base
+namespace Model
 {
     public class EventAttribute : AEventAttribute
     {
-        public EventAttribute(int type) : base(type)
+        public EventAttribute(EventIdType type) : base(type)
         {
         }
     }

+ 2 - 2
Unity/Assets/Plugins/Base/Event/EventAttribute.cs.meta → Unity/Assets/Scripts/Event/EventAttribute.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 6bfe281cef9c246428de3929dad18b42
-timeCreated: 1476427109
+guid: 46c83a3a046e502409ed650e1f3bc238
+timeCreated: 1477377275
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 2 - 2
Unity/Assets/Scripts/Event/EventIdType.cs

@@ -1,7 +1,7 @@
 namespace Model
 {
-    public static class EventIdType
+    public enum EventIdType
     {
-		public const int InitSceneStart = 1000;
+		InitSceneStart,
     }
 }

+ 1 - 1
Unity/Assets/Plugins/Base/Event/IEvent.cs → Unity/Assets/Scripts/Event/IEvent.cs

@@ -1,4 +1,4 @@
-namespace Base
+namespace Model
 {
 	public interface IEvent
 	{

+ 2 - 2
Unity/Assets/Plugins/Base/Event/IEvent.cs.meta → Unity/Assets/Scripts/Event/IEvent.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 7aede6a4fae88f2438eef33fffe6aeb5
-timeCreated: 1476427109
+guid: dab16cc3acc616f4880a9cd714ba9be0
+timeCreated: 1477377275
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 24 - 7
Unity/Assets/Scripts/Message/AppType.cs

@@ -1,12 +1,29 @@
-namespace Model
+using System;
+using System.Collections.Generic;
+
+namespace Model
 {
-	public static class AppType
+	public class ServerType: Attribute
+	{
+		
+	}
+
+	public enum AppType
 	{
-		public const string Client = "Client";
-		public const string Robot = "Robot";
+		Client,
+		Robot,
+		
+		Manager,
+		Realm,
+		Gate,
+	}
 
-		public const string Manager = "Manager";
-		public const string Realm = "Realm";
-		public const string Gate = "Gate";
+	public static class AppTypeHelper
+	{
+		public static List<AppType> GetServerTypes()
+		{
+			List<AppType> appTypes = new List<AppType>() { AppType.Manager, AppType.Realm, AppType.Gate };
+			return appTypes;
+		}
 	}
 }

+ 2 - 2
Unity/Assets/Scripts/Message/Message.cs

@@ -29,7 +29,7 @@ namespace Model
 	public class R2C_ServerLog: AMessage
 	{
 		[BsonElement("at")]
-		public string AppType { get; set; }
+		public AppType AppType { get; set; }
 		[BsonElement("a")]
 		public int AppId { get; set; }
 		[BsonElement("t")]
@@ -91,7 +91,7 @@ namespace Model
 	[BsonIgnoreExtraElements]
 	public class C2M_Reload : ARequest
 	{
-		public List<string> AppType = new List<string>();
+		public List<AppType> AppType = new List<AppType>();
 	}
 
 	[Message(11)]

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

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

+ 0 - 9
Unity/Assets/Scripts/Other/ServerType.cs

@@ -1,9 +0,0 @@
-namespace Model
-{
-	public enum ServerType
-	{
-		Manager,
-		Realm,
-		Gate,
-	}
-}

+ 0 - 12
Unity/Assets/Scripts/Other/ServerType.cs.meta

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

+ 1 - 1
Unity/Assets/Scripts/Other/StartConfig.cs

@@ -7,7 +7,7 @@ namespace Model
 	{
 		public int AppId { get; set; }
 
-		public string AppType { get; set; }
+		public AppType AppType { get; set; }
 
 		public string ServerIP { get; set; }
 

+ 1 - 1
Unity/Controller/Event/InitSceneStartEvent_InitGame.cs

@@ -12,7 +12,7 @@ namespace Controller
 	{
 		public async void Run()
 		{
-			Game.Scene.AddComponent<MessageDispatherComponent, string>("Client");
+			Game.Scene.AddComponent<MessageDispatherComponent, AppType>(AppType.Client);
 			ClientConfig clientConfig = Game.Scene.AddComponent<ClientConfigComponent>().Config;
 			NetworkComponent networkComponent = Game.Scene.AddComponent<NetOuterComponent>();
 			Session session = networkComponent.Get(clientConfig.Address);

+ 0 - 6
Unity/Unity.CSharp.Plugins.csproj

@@ -76,12 +76,6 @@
     <Compile Include="Assets\Plugins\Base\Config\ConfigAttribute.cs" />
     <Compile Include="Assets\Plugins\Base\Config\ICategory.cs" />
     <Compile Include="Assets\Plugins\Base\DoubleMap.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\AEventAttribute.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\Env.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\EnvBaseKey.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\EventAttribute.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\EventBaseType.cs" />
-    <Compile Include="Assets\Plugins\Base\Event\IEvent.cs" />
     <Compile Include="Assets\Plugins\Base\Helper\ArrayHelper.cs" />
     <Compile Include="Assets\Plugins\Base\Helper\ByteHelper.cs" />
     <Compile Include="Assets\Plugins\Base\Helper\EnumHelper.cs" />

+ 4 - 1
Unity/Unity.CSharp.csproj

@@ -97,8 +97,12 @@
     <Compile Include="Assets\Scripts\Entity\UI.cs" />
     <Compile Include="Assets\Scripts\Config\BuffProto.cs" />
     <Compile Include="Assets\Scripts\Config\GlobalProto.cs" />
+    <Compile Include="Assets\Scripts\Event\AEventAttribute.cs" />
+    <Compile Include="Assets\Scripts\Event\Env.cs" />
     <Compile Include="Assets\Scripts\Event\EnvKey.cs" />
+    <Compile Include="Assets\Scripts\Event\EventAttribute.cs" />
     <Compile Include="Assets\Scripts\Event\EventIdType.cs" />
+    <Compile Include="Assets\Scripts\Event\IEvent.cs" />
     <Compile Include="Assets\Scripts\GameObjectHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\DllHelper.cs" />
     <Compile Include="Assets\Scripts\Init.cs" />
@@ -114,7 +118,6 @@
     <Compile Include="Assets\Scripts\Message\RpcException.cs" />
     <Compile Include="Assets\Scripts\Other\BsonClassMapRegister.cs" />
     <Compile Include="Assets\Scripts\Other\ClientConfig.cs" />
-    <Compile Include="Assets\Scripts\Other\ServerType.cs" />
     <Compile Include="Assets\Scripts\Other\StartConfig.cs" />
     <Compile Include="Assets\Scripts\Other\EntityType.cs" />
     <Compile Include="Assets\Scripts\Other\GameException.cs" />