添加RoomList

This commit is contained in:
Mili 2023-03-11 21:07:49 +08:00
parent 5e0aa6a4af
commit f7025ed27c
4 changed files with 12 additions and 7 deletions

View File

@ -84,6 +84,7 @@ void StartServer()
ListeningSocket = ServerSocket.StartListening(); ListeningSocket = ServerSocket.StartListening();
// 开始监听连接 // 开始监听连接
Config.RoomList = new(ListeningSocket);
ServerHelper.WriteLine("Listen -> " + Config.ServerPort); ServerHelper.WriteLine("Listen -> " + Config.ServerPort);
ServerHelper.WriteLine("服务器启动成功,开始监听 . . ."); ServerHelper.WriteLine("服务器启动成功,开始监听 . . .");

View File

@ -32,13 +32,13 @@ namespace Milimoe.FunGame.Server.Model
private Task? _Task = null; private Task? _Task = null;
private string _ClientName = ""; private string _ClientName = "";
private Guid Token = Guid.Empty;
private Guid CheckLoginKey = Guid.Empty; private Guid CheckLoginKey = Guid.Empty;
private string RegVerify = ""; private string RegVerify = "";
private int FailedTimes = 0; // 超过一定次数断开连接 private int FailedTimes = 0; // 超过一定次数断开连接
private string UserName = ""; private string UserName = "";
private string Password = ""; private string Password = "";
private string RoomID = ""; private string RoomID = "";
private readonly Guid Token;
private readonly ServerSocket Server; private readonly ServerSocket Server;
private readonly MySQLHelper SQLHelper; private readonly MySQLHelper SQLHelper;
private readonly MailSender? MailSender; private readonly MailSender? MailSender;
@ -298,7 +298,12 @@ namespace Milimoe.FunGame.Server.Model
return Send(socket, type, false, msg); return Send(socket, type, false, msg);
case SocketMessageType.UpdateRoom: case SocketMessageType.UpdateRoom:
break; List<Room> list = new();
if (Config.RoomList != null)
{
list = Config.RoomList.GetList();
}
return Send(socket, type, list);
case SocketMessageType.CreateRoom: case SocketMessageType.CreateRoom:
break; break;
@ -409,8 +414,7 @@ namespace Milimoe.FunGame.Server.Model
private void GetUsersCount() private void GetUsersCount()
{ {
ServerHelper.WriteLine($"目前在线客户端数量: {Config.OnlinePlayersCount}"); ServerHelper.WriteLine($"目前在线客户端数量: {Config.OnlinePlayersCount}(已登录的玩家数量:{Server.UsersCount}");
ServerHelper.WriteLine($"目前在线玩家数量: {Server.UsersCount}");
} }
private void CreateStreamReader() private void CreateStreamReader()

View File

@ -1,6 +1,7 @@
using System.Text; using System.Text;
using System.Collections; using System.Collections;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Library.Server;
namespace Milimoe.FunGame.Server.Others namespace Milimoe.FunGame.Server.Others
{ {
@ -21,6 +22,7 @@ namespace Milimoe.FunGame.Server.Others
public static FunGameInfo.FunGame FunGameType { get; } = FunGameInfo.FunGame.FunGame_Server; public static FunGameInfo.FunGame FunGameType { get; } = FunGameInfo.FunGame.FunGame_Server;
public static Hashtable OrderList { get; } = new(); public static Hashtable OrderList { get; } = new();
public static Hashtable BannedList { get; } = new(); public static Hashtable BannedList { get; } = new();
public static RoomList? RoomList { get; set; }
} }
public static class OfficialEmail public static class OfficialEmail

View File

@ -1,10 +1,8 @@
using System.Collections; using System.Collections;
using MySql.Data.MySqlClient;
using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Server.Others; using Milimoe.FunGame.Server.Others;
using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Transmittal;
using System.Xml.Linq;
namespace Milimoe.FunGame.Server.Utility namespace Milimoe.FunGame.Server.Utility
{ {
@ -12,7 +10,7 @@ namespace Milimoe.FunGame.Server.Utility
{ {
public static string GetPrefix() public static string GetPrefix()
{ {
DateTime now = System.DateTime.Now; DateTime now = DateTime.Now;
return now.AddMilliseconds(-now.Millisecond).ToString() + " " + Config.ServerName + ""; return now.AddMilliseconds(-now.Millisecond).ToString() + " " + Config.ServerName + "";
} }