mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-22 03:59:36 +08:00
update with core
This commit is contained in:
parent
eee6377dc4
commit
c3d1909bc6
@ -12,6 +12,7 @@
|
|||||||
<PackageOutputPath>C:\milimoe\FunGame\bin</PackageOutputPath>
|
<PackageOutputPath>C:\milimoe\FunGame\bin</PackageOutputPath>
|
||||||
<AssemblyVersion>1.0</AssemblyVersion>
|
<AssemblyVersion>1.0</AssemblyVersion>
|
||||||
<FileVersion>1.0</FileVersion>
|
<FileVersion>1.0</FileVersion>
|
||||||
|
<RootNamespace>Milimoe.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
12
FunGame.Server/Controller/ServerController.cs
Normal file
12
FunGame.Server/Controller/ServerController.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FunGame.Server.Controller
|
||||||
|
{
|
||||||
|
internal class ServerController
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@
|
|||||||
<AssemblyVersion>1.0</AssemblyVersion>
|
<AssemblyVersion>1.0</AssemblyVersion>
|
||||||
<FileVersion>1.0</FileVersion>
|
<FileVersion>1.0</FileVersion>
|
||||||
<AssemblyName>FunGameServer</AssemblyName>
|
<AssemblyName>FunGameServer</AssemblyName>
|
||||||
|
<RootNamespace>Milimoe.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
@ -51,8 +52,4 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Controller\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -4,14 +4,14 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System;
|
using System;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using Milimoe.FunGame.Server.Others;
|
|
||||||
using Milimoe.FunGame.Server.Utility;
|
using Milimoe.FunGame.Server.Utility;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using FunGame.Server.Model;
|
using Milimoe.FunGame.Server.Model;
|
||||||
|
using Milimoe.FunGame.Server.Others;
|
||||||
|
|
||||||
Console.Title = Config.SERVER_NAME;
|
Console.Title = Config.SERVER_NAME;
|
||||||
Console.WriteLine(FunGameEnum.GetInfo(Config.FunGameType));
|
Console.WriteLine(FunGameEnum.GetInfo((FunGameEnum.FunGame)Config.FunGameType));
|
||||||
|
|
||||||
bool Running = true;
|
bool Running = true;
|
||||||
Socket? ServerSocket = null;
|
Socket? ServerSocket = null;
|
||||||
@ -65,7 +65,7 @@ void StartServer()
|
|||||||
if (!INIHelper.ExistINIFile())
|
if (!INIHelper.ExistINIFile())
|
||||||
{
|
{
|
||||||
ServerHelper.WriteLine("未检测到配置文件,将自动创建配置文件 . . .");
|
ServerHelper.WriteLine("未检测到配置文件,将自动创建配置文件 . . .");
|
||||||
INIHelper.Init(Config.FunGameType);
|
INIHelper.Init((FunGameEnum.FunGame)Config.FunGameType);
|
||||||
ServerHelper.WriteLine("配置文件FunGame.ini创建成功,请修改该配置文件,然后重启服务器。");
|
ServerHelper.WriteLine("配置文件FunGame.ini创建成功,请修改该配置文件,然后重启服务器。");
|
||||||
ServerHelper.WriteLine("请输入 help 来获取帮助,输入 quit 关闭服务器。");
|
ServerHelper.WriteLine("请输入 help 来获取帮助,输入 quit 关闭服务器。");
|
||||||
return;
|
return;
|
||||||
@ -114,7 +114,7 @@ void StartServer()
|
|||||||
ServerHelper.WriteLine("客户端" + clientIPaddress + "连接 . . .");
|
ServerHelper.WriteLine("客户端" + clientIPaddress + "连接 . . .");
|
||||||
if (Read(socket, clientIPaddress) && Send(socket, clientIPaddress))
|
if (Read(socket, clientIPaddress) && Send(socket, clientIPaddress))
|
||||||
{
|
{
|
||||||
ClientSocket cs = new(socket, Running);
|
ServerModel cs = new(socket, Running);
|
||||||
Task t = Task.Factory.StartNew(() =>
|
Task t = Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
cs.Start();
|
cs.Start();
|
||||||
|
@ -12,12 +12,12 @@ using MySqlX.XDevAPI.Common;
|
|||||||
using Milimoe.FunGame.Server.Utility;
|
using Milimoe.FunGame.Server.Utility;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using Milimoe.FunGame.Server.Others;
|
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Server.Others;
|
||||||
|
|
||||||
namespace FunGame.Server.Model
|
namespace Milimoe.FunGame.Server.Model
|
||||||
{
|
{
|
||||||
public class ClientSocket
|
public class ServerModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Public
|
* Public
|
||||||
@ -32,7 +32,7 @@ namespace FunGame.Server.Model
|
|||||||
*/
|
*/
|
||||||
private User? User = null;
|
private User? User = null;
|
||||||
|
|
||||||
public ClientSocket(Socket socket, bool running)
|
public ServerModel(Socket socket, bool running)
|
||||||
{
|
{
|
||||||
Socket = socket;
|
Socket = socket;
|
||||||
Running = running;
|
Running = running;
|
48
FunGame.Server/Others/Config.cs
Normal file
48
FunGame.Server/Others/Config.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Server.Others
|
||||||
|
{
|
||||||
|
public static class Config
|
||||||
|
{
|
||||||
|
public static string SERVER_NAME { get; set; } = "FunGame Server"; // 服务器名称
|
||||||
|
public static int SERVER_PORT { get; set; } = 22222; // 默认端口
|
||||||
|
public static int SERVER_STATUS { get; set; } = 1; // 默认状态:1可连接 0不可连接 -1不可用
|
||||||
|
public static string SERVER_NOTICE { get; set; } = ""; // 服务器的公告
|
||||||
|
public static string SERVER_PASSWORD { get; set; } = ""; // 服务器的密码
|
||||||
|
public static string SERVER_DESCRIBE { get; set; } = ""; // 服务器的描述
|
||||||
|
public static string SERVER_KEY { get; set; } = ""; // 注册社区服务器的Key
|
||||||
|
public static int MAX_PLAYERS { get; set; } = 20; // 最多接受连接的玩家数量
|
||||||
|
public static int MAX_CONNECTFAILED { get; set; } = 5; // 最大连接失败次数
|
||||||
|
public static int ONLINE_PLAYERS { get; set; } = 0; // 已连接的玩家数量
|
||||||
|
public static int CONNECTING_PLAYERS { get; set; } = 0; // 正在连接的玩家数量
|
||||||
|
public static Encoding DEFAULT_ENCODING { get; } = General.DEFAULT_ENCODING; // 默认传输字符集
|
||||||
|
public static int FunGameType { get; } = (int)FunGameEnum.FunGame.FunGame_Server;
|
||||||
|
|
||||||
|
public static Hashtable OrderList { get; } = new();
|
||||||
|
|
||||||
|
public static Hashtable OnlineClients { get; } = new Hashtable();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// string: 玩家标识ID
|
||||||
|
/// Task:玩家线程
|
||||||
|
/// </summary>
|
||||||
|
public static ConcurrentDictionary<string, Task> OnlinePlayers { get; } = new ConcurrentDictionary<string, Task>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* string:房间号
|
||||||
|
* Task:玩家线程
|
||||||
|
*/
|
||||||
|
public static ConcurrentDictionary<string, Task> PlayingPlayers { get; } = new ConcurrentDictionary<string, Task>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Server.Others
|
|
||||||
{
|
|
||||||
public static class Config
|
|
||||||
{
|
|
||||||
public static string SERVER_NAME = "FunGame Server"; // 服务器名称
|
|
||||||
public static int SERVER_PORT = 22222; // 默认端口
|
|
||||||
public static int SERVER_STATUS = 1; // 默认状态:1可连接 0不可连接 -1不可用
|
|
||||||
public static string SERVER_NOTICE = ""; // 服务器的公告
|
|
||||||
public static string SERVER_PASSWORD = ""; // 服务器的密码
|
|
||||||
public static string SERVER_DESCRIBE = ""; // 服务器的描述
|
|
||||||
public static string SERVER_KEY = ""; // 注册社区服务器的Key
|
|
||||||
public static int MAX_PLAYERS = 20; // 最多接受连接的玩家数量
|
|
||||||
public static int MAX_CONNECTFAILED = 5; // 最大连接失败次数
|
|
||||||
public static int ONLINE_PLAYERS = 0; // 已连接的玩家数量
|
|
||||||
public static int CONNECTING_PLAYERS = 0; // 正在连接的玩家数量
|
|
||||||
public static Encoding DEFAULT_ENCODING = Encoding.UTF8; // 默认传输字符集
|
|
||||||
public static FunGameEnum.FunGame FunGameType = FunGameEnum.FunGame.FunGame_Server;
|
|
||||||
|
|
||||||
public static Hashtable OrderList = new();
|
|
||||||
|
|
||||||
public static Hashtable OnlineClients = new Hashtable();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// string: 玩家标识ID
|
|
||||||
/// Task:玩家线程
|
|
||||||
/// </summary>
|
|
||||||
public static ConcurrentDictionary<string, Task> OnlinePlayers = new ConcurrentDictionary<string, Task>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* string:房间号
|
|
||||||
* Task:玩家线程
|
|
||||||
*/
|
|
||||||
public static ConcurrentDictionary<string, Task> PlayingPlayers= new ConcurrentDictionary<string, Task>();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,8 +7,8 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using Milimoe.FunGame.Server.Others;
|
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Server.Others;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Server.Utility
|
namespace Milimoe.FunGame.Server.Utility
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user