移动Library.Server到Library.Common.Architecture (#11)

* 移动Library.Server到Library.Common.Architecture
This commit is contained in:
milimoe 2023-04-10 00:44:59 +08:00 committed by GitHub
parent 01ba44fab6
commit c9a7ea88b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 27 deletions

View File

@ -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

View File

@ -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
{

View File

@ -28,4 +28,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Library\Server\" />
</ItemGroup>
</Project>

View File

@ -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
{

View File

@ -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);

View File

@ -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
{

View File

@ -1,4 +1,4 @@
namespace Milimoe.FunGame.Core.Library.Server
namespace Milimoe.FunGame.Core.Library.Common.Architecture
{
public class SQLServerInfo
{

View File

@ -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
{

View File

@ -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<BaseModel> GetUsersList => OnlineUsers.GetList();
public List<IServerModel> GetUsersList => OnlineUsers.GetList();
public List<string> 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];
}

View File

@ -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
{

View File

@ -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
/// <summary>
/// 可参与高并发的字典,但添加效率较低
/// </summary>
private ConcurrentDictionary<string, BaseModel> Models { get; } = new();
private ConcurrentDictionary<string, IServerModel> Models { get; } = new();
/// <summary>
/// Init ModelManager
@ -39,7 +39,7 @@ namespace Milimoe.FunGame.Core.Service
/// </summary>
/// <param name="name">Model的Key</param>
/// <returns>Model对象</returns>
internal BaseModel this[string name] => Models[name];
internal IServerModel this[string name] => Models[name];
/// <summary>
/// 向Model管理器中添加Model
@ -47,7 +47,7 @@ namespace Milimoe.FunGame.Core.Service
/// <param name="name">Model的Key</param>
/// <param name="t">Model对象</param>
/// <returns>True操作成功</returns>
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
/// <param name="name">Model的Key</param>
/// <param name="t">Model对象</param>
/// <returns>被移除的Model</returns>
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
/// </summary>
/// <param name="name">Model的Key</param>
/// <returns>被移除的Model</returns>
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
/// <summary>
/// 获取Model对象的列表
/// </summary>
internal List<BaseModel> GetList()
internal List<IServerModel> GetList()
{
return Models.Values.ToList();
}