diff --git a/Api/Utility/General.cs b/Api/Utility/General.cs index 7b7851b..c7e7adc 100644 --- a/Api/Utility/General.cs +++ b/Api/Utility/General.cs @@ -1,4 +1,5 @@ -using System.Net.NetworkInformation; +using System.Collections; +using System.Net.NetworkInformation; using System.Security.Cryptography; using System.Text.RegularExpressions; using Milimoe.FunGame.Core.Library.Constant; @@ -56,7 +57,7 @@ namespace Milimoe.FunGame.Core.Api.Utility /// /// /// - public static ErrorType IsServerAddress(string str) + public static ErrorIPAddressType IsServerAddress(string str) { string[] strs = str.Split(':'); string ip; @@ -71,11 +72,11 @@ namespace Milimoe.FunGame.Core.Api.Utility ip = strs[0]; port = Convert.ToInt32(strs[1]); } - else return ErrorType.WrongFormat; - if (IsIP(ip) && port > 0 && port < 65536) return ErrorType.None; - else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorType.IsNotIP; - else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorType.IsNotPort; - else return ErrorType.WrongFormat; + else return ErrorIPAddressType.WrongFormat; + if (IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.None; + else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.IsNotIP; + else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorIPAddressType.IsNotPort; + else return ErrorIPAddressType.WrongFormat; } /// @@ -84,12 +85,12 @@ namespace Milimoe.FunGame.Core.Api.Utility /// /// /// - public static ErrorType IsServerAddress(string ip, int port) + public static ErrorIPAddressType IsServerAddress(string ip, int port) { - if (IsIP(ip) && port > 0 && port < 65536) return ErrorType.None; - else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorType.IsNotIP; - else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorType.IsNotPort; - else return ErrorType.WrongFormat; + if (IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.None; + else if (!IsIP(ip) && port > 0 && port < 65536) return ErrorIPAddressType.IsNotIP; + else if (IsIP(ip) && (port <= 0 || port >= 65536)) return ErrorIPAddressType.IsNotPort; + else return ErrorIPAddressType.WrongFormat; } /// @@ -136,6 +137,18 @@ namespace Milimoe.FunGame.Core.Api.Utility { return Service.JsonManager.GetObject(json); } + + /// + /// 反序列化Hashtable中的Json对象 + /// + /// + /// + /// + /// + public static T? JsonDeserializeFromHashtable(Hashtable hashtable, string key) + { + return Service.JsonManager.GetObject(hashtable, key); + } } #endregion diff --git a/Library/Constant/StateEnum.cs b/Library/Constant/StateEnum.cs index 347d116..5078d64 100644 --- a/Library/Constant/StateEnum.cs +++ b/Library/Constant/StateEnum.cs @@ -11,8 +11,9 @@ public enum RoomState { Created, + Closed, + Matching, Gaming, - Close, Complete } diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index 136e86c..4450c5b 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -95,7 +95,7 @@ Server } - public enum ErrorType + public enum ErrorIPAddressType { None, IsNotIP,