mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-23 12:39:36 +08:00

* 添加 Web API 和 RESTful API 模式; * 添加 SQLite 模式; * 添加 ISocketMessageProcessor 和 ISocketListener<> 接口,用于统一数据访问; * 重做了 ISocketModel; * 完善了 WebSocket 的连接模式。
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using Milimoe.FunGame.Core.Api.Utility;
|
|
|
|
namespace Milimoe.FunGame.Server.Utility
|
|
{
|
|
public class ConnectProperties
|
|
{
|
|
public static string Name { get; set; } = "";
|
|
public static string DataSource { get; set; } = "";
|
|
public static string Port { get; set; } = "";
|
|
public static string DataBase { get; set; } = "";
|
|
public static string User { get; set; } = "";
|
|
public static string Password { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// 读取MySQL服务器配置文件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetConnectPropertiesForMySQL()
|
|
{
|
|
if (Name == "" && DataSource == "" && Port == "" && DataBase == "" && User == "" && Password == "")
|
|
{
|
|
if (INIHelper.ExistINIFile())
|
|
{
|
|
DataSource = INIHelper.ReadINI("MySQL", "DBServer");
|
|
Port = INIHelper.ReadINI("MySQL", "DBPort");
|
|
DataBase = INIHelper.ReadINI("MySQL", "DBName");
|
|
User = INIHelper.ReadINI("MySQL", "DBUser");
|
|
Password = INIHelper.ReadINI("MySQL", "DBPassword");
|
|
}
|
|
else ServerHelper.Error(new MySQLConfigException());
|
|
}
|
|
return "data source = " + DataSource + "; port = " + Port + "; database = " + DataBase + "; user = " + User + "; password = " + Password + "; charset = utf8mb4;";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 读取SQLite服务器配置文件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetConnectPropertiesForSQLite()
|
|
{
|
|
if (DataSource == "")
|
|
{
|
|
if (INIHelper.ExistINIFile())
|
|
{
|
|
DataSource = INIHelper.ReadINI("SQLite", "DataSource");
|
|
}
|
|
else ServerHelper.Error(new SQLServiceException());
|
|
}
|
|
return "data source=" + DataSource;
|
|
}
|
|
}
|
|
}
|