mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-21 11:39:35 +08:00
为ServerSocket添加UserList
This commit is contained in:
parent
c6c084c020
commit
4558110af9
@ -9,7 +9,7 @@ namespace Milimoe.FunGame.Core.Interface.Base
|
||||
public abstract bool Running { get; }
|
||||
public abstract ClientSocket? Socket { get; }
|
||||
public abstract Task? Task { get; }
|
||||
public abstract User? User { get; }
|
||||
public abstract User User { get; }
|
||||
public abstract string ClientName { get; }
|
||||
|
||||
public abstract bool Read(ClientSocket socket);
|
||||
|
@ -15,20 +15,29 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
public string ServerNotice { get; } = "";
|
||||
public bool Connected => Instance != null && Instance.Connected;
|
||||
public List<IServerModel> ClientList => OnlineClients.GetList();
|
||||
public List<IServerModel> UserList => OnlineUsers.GetList();
|
||||
public List<string> BannedList { get; } = new();
|
||||
public int ClientCount => OnlineClients.Count;
|
||||
public int UserCount => OnlineUsers.Count;
|
||||
public int BannedCount => BannedList.Count;
|
||||
|
||||
private readonly ModelManager<IServerModel> OnlineClients;
|
||||
private readonly ModelManager<IServerModel> OnlineUsers;
|
||||
|
||||
private ServerSocket(System.Net.Sockets.Socket Instance, int ServerPort, int MaxConnection = 0)
|
||||
{
|
||||
this.Instance = Instance;
|
||||
this.ServerPort = ServerPort;
|
||||
if (MaxConnection <= 0)
|
||||
{
|
||||
OnlineClients = new();
|
||||
OnlineUsers = new();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnlineClients = new(MaxConnection);
|
||||
OnlineUsers = new(MaxConnection);
|
||||
}
|
||||
}
|
||||
|
||||
public static ServerSocket StartListening(int Port = 22222, int MaxConnection = 0)
|
||||
@ -51,30 +60,54 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
throw new SocketGetClientException();
|
||||
}
|
||||
|
||||
public bool Add(string name, IServerModel t)
|
||||
public bool AddClient(string name, IServerModel t)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineClients.Add(name, t);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
public bool RemoveClient(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineClients.Remove(name);
|
||||
}
|
||||
|
||||
public bool Contains(string name)
|
||||
public bool ContainsClient(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineClients.ContainsKey(name);
|
||||
}
|
||||
|
||||
public IServerModel Get(string name)
|
||||
public IServerModel GetClient(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineClients[name];
|
||||
}
|
||||
|
||||
public bool AddUser(string name, IServerModel t)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineUsers.Add(name, t);
|
||||
}
|
||||
|
||||
public bool RemoveUser(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineUsers.Remove(name);
|
||||
}
|
||||
|
||||
public bool ContainsUser(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineUsers.ContainsKey(name);
|
||||
}
|
||||
|
||||
public IServerModel GetUser(string name)
|
||||
{
|
||||
name = name.ToLower();
|
||||
return OnlineUsers[name];
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Instance?.Close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user