diff --git a/Api/Transmittal/MailSender.cs b/Api/Transmittal/MailSender.cs index 4d8bec2..086fedc 100644 --- a/Api/Transmittal/MailSender.cs +++ b/Api/Transmittal/MailSender.cs @@ -1,7 +1,7 @@ using System.Net.Mail; +using Milimoe.FunGame.Core.Library.Common.Architecture; using Milimoe.FunGame.Core.Library.Common.Network; using Milimoe.FunGame.Core.Library.Constant; -using Milimoe.FunGame.Core.Library.Server; using Milimoe.FunGame.Core.Service; namespace Milimoe.FunGame.Core.Api.Transmittal diff --git a/Api/Transmittal/SQLHelper.cs b/Api/Transmittal/SQLHelper.cs index 23f0bf4..4b8e475 100644 --- a/Api/Transmittal/SQLHelper.cs +++ b/Api/Transmittal/SQLHelper.cs @@ -1,7 +1,7 @@ using System.Data; using Milimoe.FunGame.Core.Interface.Base; +using Milimoe.FunGame.Core.Library.Common.Architecture; using Milimoe.FunGame.Core.Library.Constant; -using Milimoe.FunGame.Core.Library.Server; namespace Milimoe.FunGame.Core.Api.Transmittal { diff --git a/FunGame.Core.csproj b/FunGame.Core.csproj index 0d190d8..9d38ced 100644 --- a/FunGame.Core.csproj +++ b/FunGame.Core.csproj @@ -28,4 +28,8 @@ + + + + diff --git a/Interface/Base/ISQLHelper.cs b/Interface/Base/ISQLHelper.cs index a671483..7f2dbd6 100644 --- a/Interface/Base/ISQLHelper.cs +++ b/Interface/Base/ISQLHelper.cs @@ -1,6 +1,6 @@ -using Milimoe.FunGame.Core.Library.Constant; -using Milimoe.FunGame.Core.Library.Server; -using System.Data; +using System.Data; +using Milimoe.FunGame.Core.Library.Common.Architecture; +using Milimoe.FunGame.Core.Library.Constant; namespace Milimoe.FunGame.Core.Interface.Base { diff --git a/Library/Server/BaseModel.cs b/Interface/Base/IServerModel.cs similarity index 87% rename from Library/Server/BaseModel.cs rename to Interface/Base/IServerModel.cs index 9d8017a..10b25c3 100644 --- a/Library/Server/BaseModel.cs +++ b/Interface/Base/IServerModel.cs @@ -2,15 +2,15 @@ using Milimoe.FunGame.Core.Library.Common.Network; using Milimoe.FunGame.Core.Library.Constant; -namespace Milimoe.FunGame.Core.Library.Server +namespace Milimoe.FunGame.Core.Interface.Base { - public abstract class BaseModel + public interface IServerModel { public abstract bool Running { get; } public abstract ClientSocket? Socket { get; } public abstract Task? Task { get; } - public abstract string ClientName { get; } public abstract User? User { get; } + public abstract string ClientName { get; } public abstract bool Read(ClientSocket socket); public abstract bool Send(ClientSocket socket, SocketMessageType type, params object[] objs); diff --git a/Library/Server/RoomList.cs b/Library/Common/Architecture/RoomList.cs similarity index 95% rename from Library/Server/RoomList.cs rename to Library/Common/Architecture/RoomList.cs index 514dd25..72c597b 100644 --- a/Library/Server/RoomList.cs +++ b/Library/Common/Architecture/RoomList.cs @@ -2,7 +2,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Common.Network; -namespace Milimoe.FunGame.Core.Library.Server +namespace Milimoe.FunGame.Core.Library.Common.Architecture { public class RoomList { @@ -22,7 +22,7 @@ namespace Milimoe.FunGame.Core.Library.Server public Hashtable GetHashTable => _List; public List GetRoomList => _List.Values.Cast().ToList(); - + public List GetRoomIDList => _List.Keys.Cast().ToList(); public void Clear() @@ -34,7 +34,7 @@ namespace Milimoe.FunGame.Core.Library.Server { _List.Add(Room.Roomid, Room); } - + public void AddRooms(List Rooms) { foreach (Room Room in Rooms) @@ -42,7 +42,7 @@ namespace Milimoe.FunGame.Core.Library.Server _List.Add(Room.Roomid, Room); } } - + public void RemoveRoom(Room Room) { _List.Remove(Room.Roomid); diff --git a/Library/Server/SQLServerInfo.cs b/Library/Common/Architecture/SQLServerInfo.cs similarity index 96% rename from Library/Server/SQLServerInfo.cs rename to Library/Common/Architecture/SQLServerInfo.cs index 8578dfe..87a430b 100644 --- a/Library/Server/SQLServerInfo.cs +++ b/Library/Common/Architecture/SQLServerInfo.cs @@ -1,4 +1,4 @@ -namespace Milimoe.FunGame.Core.Library.Server +namespace Milimoe.FunGame.Core.Library.Common.Architecture { public class SQLServerInfo { diff --git a/Library/Server/SmtpClientInfo.cs b/Library/Common/Architecture/SmtpClientInfo.cs similarity index 94% rename from Library/Server/SmtpClientInfo.cs rename to Library/Common/Architecture/SmtpClientInfo.cs index d220375..5f00536 100644 --- a/Library/Server/SmtpClientInfo.cs +++ b/Library/Common/Architecture/SmtpClientInfo.cs @@ -1,6 +1,6 @@ using Milimoe.FunGame.Core.Interface.Base; -namespace Milimoe.FunGame.Core.Library.Server +namespace Milimoe.FunGame.Core.Library.Common.Architecture { public class SmtpClientInfo : IMailSender { diff --git a/Library/Common/Network/ServerSocket.cs b/Library/Common/Network/ServerSocket.cs index 0e09cdb..761de45 100644 --- a/Library/Common/Network/ServerSocket.cs +++ b/Library/Common/Network/ServerSocket.cs @@ -1,6 +1,5 @@ using Milimoe.FunGame.Core.Interface.Base; using Milimoe.FunGame.Core.Library.Constant; -using Milimoe.FunGame.Core.Library.Server; using Milimoe.FunGame.Core.Service; namespace Milimoe.FunGame.Core.Library.Common.Network @@ -15,7 +14,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network public string ServerName { get; } = ""; public string ServerNotice { get; } = ""; public bool Connected => Instance != null && Instance.Connected; - public List GetUsersList => OnlineUsers.GetList(); + public List GetUsersList => OnlineUsers.GetList(); public List BannedList { get; } = new(); public int UsersCount => OnlineUsers.Count; public int BannedCount => BannedList.Count; @@ -52,7 +51,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network throw new SocketGetClientException(); } - public bool AddUser(string UserName, BaseModel t) + public bool AddUser(string UserName, IServerModel t) { return OnlineUsers.Add(UserName, t); } @@ -67,7 +66,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network return OnlineUsers.ContainsKey(UserName); } - public BaseModel GetUser(string UserName) + public IServerModel GetUser(string UserName) { return OnlineUsers[UserName]; } diff --git a/Service/MailManager.cs b/Service/MailManager.cs index c39e983..7078d6b 100644 --- a/Service/MailManager.cs +++ b/Service/MailManager.cs @@ -2,10 +2,10 @@ using System.Net; using System.Net.Mail; using Milimoe.FunGame.Core.Api.Transmittal; +using Milimoe.FunGame.Core.Library.Common.Architecture; using Milimoe.FunGame.Core.Library.Common.Network; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Exception; -using Milimoe.FunGame.Core.Library.Server; namespace Milimoe.FunGame.Core.Service { diff --git a/Service/ModelManager.cs b/Service/ModelManager.cs index 447116a..bf15083 100644 --- a/Service/ModelManager.cs +++ b/Service/ModelManager.cs @@ -1,5 +1,5 @@ using System.Collections.Concurrent; -using Milimoe.FunGame.Core.Library.Server; +using Milimoe.FunGame.Core.Interface.Base; namespace Milimoe.FunGame.Core.Service { @@ -18,7 +18,7 @@ namespace Milimoe.FunGame.Core.Service /// /// 可参与高并发的字典,但添加效率较低 /// - private ConcurrentDictionary Models { get; } = new(); + private ConcurrentDictionary Models { get; } = new(); /// /// Init ModelManager @@ -39,7 +39,7 @@ namespace Milimoe.FunGame.Core.Service /// /// Model的Key /// Model对象 - internal BaseModel this[string name] => Models[name]; + internal IServerModel this[string name] => Models[name]; /// /// 向Model管理器中添加Model @@ -47,7 +47,7 @@ namespace Milimoe.FunGame.Core.Service /// Model的Key /// Model对象 /// True:操作成功 - internal bool Add(string name, BaseModel t) + internal bool Add(string name, IServerModel t) { if (Models.Count + 1 > MaxModel) return false; return Models.TryAdd(name, t); @@ -69,7 +69,7 @@ namespace Milimoe.FunGame.Core.Service /// Model的Key /// Model对象 /// 被移除的Model - internal bool Remove(string name, ref BaseModel? t) + internal bool Remove(string name, ref IServerModel? t) { return Models.TryRemove(name, out t); } @@ -79,9 +79,9 @@ namespace Milimoe.FunGame.Core.Service /// /// Model的Key /// 被移除的Model - internal BaseModel? RemoveAndGet(string name) + internal IServerModel? RemoveAndGet(string name) { - Models.TryRemove(name, out BaseModel? result); + Models.TryRemove(name, out IServerModel? result); return result; } @@ -102,7 +102,7 @@ namespace Milimoe.FunGame.Core.Service /// /// 获取Model对象的列表 /// - internal List GetList() + internal List GetList() { return Models.Values.ToList(); }