milimoe 7a6b40800d
修改架构 (#24)
* 添加ServerController;DataRequest添加GetNotice

* DataRequest添加Reg

* 添加RoomS

* 修改架构之Connect

* 迁移其他的Socket业务至DataRequest

* 更新连接服务器的逻辑

* 修改架构之Login

* 更新Core

* 修复IntoRoom Bug

* 修复ForceLogOut Bug

* 修复CreateRoom QuitRoom IntoRoom

* 修复QuitRoom Bug和进入房间的广播

* 添加查看列表指令,完善kick和forcelogout

* 数量显示错误

* 修复QuitRoom ConnectingCount Bug
2023-09-14 22:15:18 +08:00

87 lines
3.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Milimoe.FunGame.Core.Interface;
using Milimoe.FunGame.Core.Interface.Base;
using Milimoe.FunGame.Core.Library.Common.Network;
using Milimoe.FunGame.Server.Others;
using Milimoe.FunGame.Server.Utility;
namespace Milimoe.FunGame.Server.Model
{
public class ConsoleModel
{
public static void Order(ServerSocket? server, string order)
{
try
{
switch (order)
{
case OrderDictionary.Kick:
{
ServerHelper.Write("输入需要踢出的客户端名称:");
string client = Console.ReadLine() ?? "";
if (client != "" && server != null)
{
((ServerModel)server.GetClient(client))?.Kick("您已被服务器管理员踢出此服务器。");
}
break;
}
case OrderDictionary.Logout:
{
ServerHelper.Write("输入需要强制下线的玩家ID");
string user = Console.ReadLine() ?? "";
if (user != "" && server != null)
{
((ServerModel)server.GetUser(user))?.ForceLogOut("您已被服务器管理员强制下线。");
}
break;
}
case OrderDictionary.ShowList:
ShowClients(server);
ShowUsers(server);
break;
case OrderDictionary.ShowClients1:
case OrderDictionary.ShowClients2:
ShowClients(server);
break;
case OrderDictionary.ShowUsers1:
case OrderDictionary.ShowUsers2:
ShowUsers(server);
break;
case OrderDictionary.Help:
ServerHelper.WriteLine("Milimoe -> 帮助");
break;
}
}
catch (Exception e)
{
ServerHelper.Error(e);
}
}
private static void ShowClients(ServerSocket? server)
{
if (server != null)
{
ServerHelper.WriteLine("显示在线客户端列表");
int index = 1;
foreach (IServerModel client in server.ClientList)
{
ServerHelper.WriteLine(index++ + ". " + client.ClientName + (client.User.Id != 0 ? " (已登录为:" + client.User.Username + ")" : ""));
}
}
}
private static void ShowUsers(ServerSocket? server)
{
if (server != null)
{
ServerHelper.WriteLine("显示在线玩家列表");
int index = 1;
foreach (IServerModel user in server.UserList.Where(u => u.User.Id != 0))
{
ServerHelper.WriteLine(index++ + ". " + (user.User.Username) + " (客户端:" + user.ClientName + ")");
}
}
}
}
}