mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-12-05 08:09:03 +00:00
修改User构造方法
This commit is contained in:
parent
f7382b7d04
commit
4c9b729463
@ -39,6 +39,10 @@
|
|||||||
<HintPath>..\..\FunGame\bin\Server\Debug\net6.0\MySql.Data.dll</HintPath>
|
<HintPath>..\..\FunGame\bin\Server\Debug\net6.0\MySql.Data.dll</HintPath>
|
||||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\..\FunGame\bin\Debug\net7.0-windows\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Configuration.ConfigurationManager">
|
<Reference Include="System.Configuration.ConfigurationManager">
|
||||||
<HintPath>..\..\FunGame\bin\Server\Debug\net6.0\System.Configuration.ConfigurationManager.dll</HintPath>
|
<HintPath>..\..\FunGame\bin\Server\Debug\net6.0\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
private string RegVerify = "";
|
private string RegVerify = "";
|
||||||
private int FailedTimes = 0; // 超过一定次数断开连接
|
private int FailedTimes = 0; // 超过一定次数断开连接
|
||||||
private string UserName = "";
|
private string UserName = "";
|
||||||
private string Password = "";
|
private DataSet UserDataSet = new();
|
||||||
private string RoomID = "";
|
private string RoomID = "";
|
||||||
private readonly Guid Token;
|
private readonly Guid Token;
|
||||||
private readonly ServerSocket Server;
|
private readonly ServerSocket Server;
|
||||||
@ -106,11 +106,23 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
SQLHelper.ExecuteDataSet(UserQuery.Select_Users_LoginQuery(username, password), out SQLResult result);
|
SQLHelper.ExecuteDataSet(UserQuery.Select_Users_LoginQuery(username, password), out SQLResult result);
|
||||||
if (result == SQLResult.Success)
|
if (result == SQLResult.Success)
|
||||||
{
|
{
|
||||||
DataRow UserRow = SQLHelper.DataSet.Tables[0].Rows[0];
|
UserDataSet = SQLHelper.DataSet;
|
||||||
|
DataRow UserRow = UserDataSet.Tables[0].Rows[0];
|
||||||
if (autokey != null && autokey.Trim() != "")
|
if (autokey != null && autokey.Trim() != "")
|
||||||
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] AutoKey: 已确认");
|
{
|
||||||
|
SQLHelper.ExecuteDataSet(UserQuery.Select_CheckAutoKey(username, autokey), out result);
|
||||||
|
if (result == SQLResult.Success)
|
||||||
|
{
|
||||||
|
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] AutoKey: 已确认");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg = "AutoKey不正确,拒绝自动登录!";
|
||||||
|
ServerHelper.WriteLine("[" + ServerSocket.GetTypeString(type) + "] " + msg);
|
||||||
|
return Send(socket, type, CheckLoginKey, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
UserName = username;
|
UserName = username;
|
||||||
Password = password;
|
|
||||||
CheckLoginKey = Guid.NewGuid();
|
CheckLoginKey = Guid.NewGuid();
|
||||||
return Send(socket, type, CheckLoginKey);
|
return Send(socket, type, CheckLoginKey);
|
||||||
}
|
}
|
||||||
@ -127,7 +139,7 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
if (CheckLoginKey.Equals(checkloginkey))
|
if (CheckLoginKey.Equals(checkloginkey))
|
||||||
{
|
{
|
||||||
// 创建User对象
|
// 创建User对象
|
||||||
_User = Factory.New<User>(UserName, Password);
|
_User = Factory.GetInstance<User>(UserDataSet);
|
||||||
// 检查有没有重复登录的情况
|
// 检查有没有重复登录的情况
|
||||||
KickUser();
|
KickUser();
|
||||||
// 添加至玩家列表
|
// 添加至玩家列表
|
||||||
@ -136,7 +148,7 @@ namespace Milimoe.FunGame.Server.Model
|
|||||||
// CheckLogin
|
// CheckLogin
|
||||||
LoginTime = DateTime.Now.Ticks;
|
LoginTime = DateTime.Now.Ticks;
|
||||||
SQLHelper.Execute(UserQuery.Update_CheckLogin(UserName, socket.ClientIP.Split(':')[0]), out _);
|
SQLHelper.Execute(UserQuery.Update_CheckLogin(UserName, socket.ClientIP.Split(':')[0]), out _);
|
||||||
return Send(socket, type, UserName, Password);
|
return Send(socket, type, UserDataSet);
|
||||||
}
|
}
|
||||||
ServerHelper.WriteLine("客户端发送了错误的秘钥,不允许本次登录。");
|
ServerHelper.WriteLine("客户端发送了错误的秘钥,不允许本次登录。");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user