mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
找回密码 第二部分 (#37)
* 常量更新 * 添加枚举:Login_UpdatePassword * 添加Hashtable反序列化方法 Server那边没有Request对象 --------- Co-authored-by: Yezi <53083103+yeziuku@users.noreply.github.com>
This commit is contained in:
parent
5a63b97341
commit
247090341f
@ -3,7 +3,6 @@ using Milimoe.FunGame.Core.Library.Common.Architecture;
|
|||||||
using Milimoe.FunGame.Core.Library.Common.Network;
|
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Core.Service;
|
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Api.Transmittal
|
namespace Milimoe.FunGame.Core.Api.Transmittal
|
||||||
{
|
{
|
||||||
@ -88,7 +87,7 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T? GetResult<T>(string key)
|
public T? GetResult<T>(string key)
|
||||||
{
|
{
|
||||||
return JsonManager.GetObject<T>(Worker.ResultData, key);
|
return GetHashtableJsonObject<T>(Worker.ResultData, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Request : BaseModel
|
private class Request : BaseModel
|
||||||
@ -158,5 +157,38 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取Type的等效字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetTypeString(DataRequestType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
DataRequestType.Main_GetNotice => DataRequestSet.Main_GetNotice,
|
||||||
|
DataRequestType.Main_CreateRoom => DataRequestSet.Main_CreateRoom,
|
||||||
|
DataRequestType.Main_UpdateRoom => DataRequestSet.Main_UpdateRoom,
|
||||||
|
DataRequestType.Reg_GetRegVerifyCode => DataRequestSet.Reg_GetRegVerifyCode,
|
||||||
|
DataRequestType.Login_GetFindPasswordVerifyCode => DataRequestSet.Login_GetFindPasswordVerifyCode,
|
||||||
|
DataRequestType.Login_UpdatePassword => DataRequestSet.Login_UpdatePassword,
|
||||||
|
DataRequestType.Room_GetRoomSettings => DataRequestSet.Room_GetRoomSettings,
|
||||||
|
DataRequestType.Room_GetRoomPlayerCount => DataRequestSet.Room_GetRoomPlayerCount,
|
||||||
|
_ => DataRequestSet.UnKnown
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化Hashtable中的Json对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="hashtable"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T? GetHashtableJsonObject<T>(Hashtable hashtable, string key)
|
||||||
|
{
|
||||||
|
return Utility.NetworkUtility.JsonDeserializeFromHashtable<T>(hashtable, key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
SocketObject result = SocketManager.Receive();
|
SocketObject result = SocketManager.Receive();
|
||||||
if (result.SocketType == SocketMessageType.HeartBeat)
|
if (result.SocketType == SocketMessageType.RunTime_HeartBeat)
|
||||||
{
|
{
|
||||||
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
||||||
_HeartBeatFaileds = 0;
|
_HeartBeatFaileds = 0;
|
||||||
@ -79,7 +79,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
|||||||
SocketObject[] result = SocketManager.ReceiveArray();
|
SocketObject[] result = SocketManager.ReceiveArray();
|
||||||
foreach (SocketObject obj in result)
|
foreach (SocketObject obj in result)
|
||||||
{
|
{
|
||||||
if (obj.SocketType == SocketMessageType.HeartBeat)
|
if (obj.SocketType == SocketMessageType.RunTime_HeartBeat)
|
||||||
{
|
{
|
||||||
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
||||||
_HeartBeatFaileds = 0;
|
_HeartBeatFaileds = 0;
|
||||||
@ -155,7 +155,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
|||||||
{
|
{
|
||||||
if (!SendingHeartBeat) _SendingHeartBeat= true;
|
if (!SendingHeartBeat) _SendingHeartBeat= true;
|
||||||
// 发送心跳包
|
// 发送心跳包
|
||||||
if (Send(SocketMessageType.HeartBeat) == SocketResult.Success)
|
if (Send(SocketMessageType.RunTime_HeartBeat) == SocketResult.Success)
|
||||||
{
|
{
|
||||||
WaitHeartBeatReply = Task.Run(() =>
|
WaitHeartBeatReply = Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
/**
|
||||||
|
* 此文件用于保存字符串常量(String Set)
|
||||||
|
*/
|
||||||
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public class InterfaceSet
|
public class InterfaceSet
|
||||||
{
|
{
|
||||||
@ -31,24 +34,42 @@
|
|||||||
public const string Socket = "Socket";
|
public const string Socket = "Socket";
|
||||||
public const string Unknown = "Unknown";
|
public const string Unknown = "Unknown";
|
||||||
public const string DataRequest = "DataRequest";
|
public const string DataRequest = "DataRequest";
|
||||||
public const string Connect = "Connect";
|
public const string RunTime_Connect = "RunTime_Connect";
|
||||||
public const string GetNotice = "GetNotice";
|
public const string RunTime_Reg = "RunTime_Reg";
|
||||||
public const string Login = "Login";
|
public const string RunTime_CheckReg = "RunTime_CheckReg";
|
||||||
public const string CheckLogin = "CheckLogin";
|
public const string RunTime_Login = "RunTime_Login";
|
||||||
public const string Logout = "Logout";
|
public const string RunTime_CheckLogin = "RunTime_CheckLogin";
|
||||||
public const string Disconnect = "Disconnect";
|
public const string RunTime_Logout = "RunTime_Logout";
|
||||||
public const string HeartBeat = "HeartBeat";
|
public const string RunTime_Disconnect = "RunTime_Disconnect";
|
||||||
public const string IntoRoom = "IntoRoom";
|
public const string RunTime_HeartBeat = "RunTime_HeartBeat";
|
||||||
public const string QuitRoom = "QuitRoom";
|
public const string Main_GetNotice = "Main_GetNotice";
|
||||||
public const string Chat = "Chat";
|
public const string Main_IntoRoom = "Main_IntoRoom";
|
||||||
public const string Reg = "Reg";
|
public const string Main_QuitRoom = "Main_QuitRoom";
|
||||||
public const string CheckReg = "CheckReg";
|
public const string Main_Chat = "Main_Chat";
|
||||||
public const string CreateRoom = "CreateRoom";
|
public const string Main_CreateRoom = "Main_CreateRoom";
|
||||||
public const string UpdateRoom = "UpdateRoom";
|
public const string Main_UpdateRoom = "Main_UpdateRoom";
|
||||||
public const string ChangeRoomSetting = "ChangeRoomSetting";
|
public const string Main_MatchRoom = "Main_MatchRoom";
|
||||||
public const string MatchRoom = "MatchRoom";
|
public const string Room_ChangeRoomSetting = "Room_ChangeRoomSetting";
|
||||||
public const string UpdateRoomMaster = "UpdateRoomMaster";
|
public const string Room_UpdateRoomMaster = "Room_UpdateRoomMaster";
|
||||||
public const string GetRoomPlayerCount = "GetRoomPlayerCount";
|
public const string Room_GetRoomPlayerCount = "Room_GetRoomPlayerCount";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 需要同步更新
|
||||||
|
/// Milimoe.FunGame.Core.Library.Constant.DataRequestType,
|
||||||
|
/// Milimoe.FunGame.Core.Api.Transmittal.DataRequest.GetTypeString(DataRequestType type)
|
||||||
|
/// </summary>
|
||||||
|
public class DataRequestSet
|
||||||
|
{
|
||||||
|
public const string UnKnown = "UnKnown";
|
||||||
|
public const string Main_GetNotice = "Main_GetNotice";
|
||||||
|
public const string Main_CreateRoom = "Main_CreateRoom";
|
||||||
|
public const string Main_UpdateRoom = "Main_UpdateRoom";
|
||||||
|
public const string Reg_GetRegVerifyCode = "Reg_GetRegVerifyCode";
|
||||||
|
public const string Login_GetFindPasswordVerifyCode = "Login_GetFindPasswordVerifyCode";
|
||||||
|
public const string Login_UpdatePassword = "Login_UpdatePassword";
|
||||||
|
public const string Room_GetRoomSettings = "Room_GetRoomSettings";
|
||||||
|
public const string Room_GetRoomPlayerCount = "Room_GetRoomPlayerCount";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReflectionSet
|
public class ReflectionSet
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
FunGame_Server
|
FunGame_Server
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string FunGame_CopyRight = @"©2023 Mili.cyou. 米粒的糖果屋";
|
public const string FunGame_CopyRight = @"©2023 Milimoe. 米粒的糖果屋";
|
||||||
|
|
||||||
private const string FunGame_Core = "FunGame Core";
|
private const string FunGame_Core = "FunGame Core";
|
||||||
private const string FunGame_Core_Api = "FunGame Core Api";
|
private const string FunGame_Core_Api = "FunGame Core Api";
|
||||||
@ -33,7 +33,7 @@
|
|||||||
FunGame.FunGame_Server => FunGame_Server,
|
FunGame.FunGame_Server => FunGame_Server,
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
return type + " [ 版本: " + FunGame_Version + FunGame_VersionPatch + " ]\n" + (type.Equals(FunGame_Desktop) ? @"©" : "(C)") + "2023 Mili.cyou. 保留所有权利\n";
|
return type + " [ 版本: " + FunGame_Version + FunGame_VersionPatch + " ]\n" + (type.Equals(FunGame_Desktop) ? @"©" : "(C)") + "2023 Milimoe. 保留所有权利\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 此文件保存常用的对象常量
|
||||||
|
*/
|
||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public class General
|
public class General
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 此文件保存Method(方法)的枚举
|
||||||
|
*/
|
||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public enum InterfaceMethod
|
public enum InterfaceMethod
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
/**
|
||||||
|
* 此文件保存Result(结果)的枚举
|
||||||
|
*/
|
||||||
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public enum MessageResult
|
public enum MessageResult
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
/**
|
||||||
|
* 此文件保存State(状态)的枚举
|
||||||
|
*/
|
||||||
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public enum StartMatchState
|
public enum StartMatchState
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
namespace Milimoe.FunGame.Core.Library.Constant
|
/**
|
||||||
|
* 此文件保存Type(类型)的枚举
|
||||||
|
*/
|
||||||
|
namespace Milimoe.FunGame.Core.Library.Constant
|
||||||
{
|
{
|
||||||
public enum FormType
|
public enum FormType
|
||||||
{
|
{
|
||||||
@ -56,37 +59,41 @@
|
|||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
DataRequest,
|
DataRequest,
|
||||||
Connect,
|
RunTime_Connect,
|
||||||
GetNotice,
|
RunTime_Reg,
|
||||||
Login,
|
RunTime_CheckReg,
|
||||||
CheckLogin,
|
RunTime_Login,
|
||||||
Logout,
|
RunTime_CheckLogin,
|
||||||
ForceLogout,
|
RunTime_Logout,
|
||||||
Disconnect,
|
RunTime_ForceLogout,
|
||||||
HeartBeat,
|
RunTime_Disconnect,
|
||||||
IntoRoom,
|
RunTime_HeartBeat,
|
||||||
QuitRoom,
|
Main_GetNotice,
|
||||||
Chat,
|
Main_IntoRoom,
|
||||||
Reg,
|
Main_QuitRoom,
|
||||||
CheckReg,
|
Main_Chat,
|
||||||
CreateRoom,
|
Main_CreateRoom,
|
||||||
UpdateRoom,
|
Main_UpdateRoom,
|
||||||
ChangeRoomSetting,
|
Main_MatchRoom,
|
||||||
MatchRoom,
|
Room_ChangeRoomSetting,
|
||||||
UpdateRoomMaster,
|
Room_UpdateRoomMaster,
|
||||||
GetRoomPlayerCount
|
Room_GetRoomPlayerCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 需要同步更新Milimoe.FunGame.Core.Library.Constant.DataRequestSet
|
||||||
|
/// </summary>
|
||||||
public enum DataRequestType
|
public enum DataRequestType
|
||||||
{
|
{
|
||||||
UnKnown,
|
UnKnown,
|
||||||
GetNotice,
|
Main_GetNotice,
|
||||||
GetRegVerifyCode,
|
Main_CreateRoom,
|
||||||
CreateRoom,
|
Main_UpdateRoom,
|
||||||
UpdateRoom,
|
Reg_GetRegVerifyCode,
|
||||||
GetRoomSettings,
|
Login_GetFindPasswordVerifyCode,
|
||||||
GetRoomPlayerCount,
|
Login_UpdatePassword,
|
||||||
GetFindPasswordVerifyCode
|
Room_GetRoomSettings,
|
||||||
|
Room_GetRoomPlayerCount
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SocketRuntimeType
|
public enum SocketRuntimeType
|
||||||
|
|||||||
@ -55,6 +55,11 @@
|
|||||||
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_LastTime} = '{DateTime.Now}', {Column_LastIP} = '{IP}' {Constant.Command_Where} {Column_Username} = '{Username}'";
|
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_LastTime} = '{DateTime.Now}', {Column_LastIP} = '{IP}' {Constant.Command_Where} {Column_Username} = '{Username}'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string Update_Password(string Username, string Password)
|
||||||
|
{
|
||||||
|
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_Password} = '{Password}' {Constant.Command_Where} {Column_Username} = '{Username}'";
|
||||||
|
}
|
||||||
|
|
||||||
public static string Update_GameTime(string Username, int GameTimeMinutes)
|
public static string Update_GameTime(string Username, int GameTimeMinutes)
|
||||||
{
|
{
|
||||||
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_GameTime} = {Column_GameTime} + {GameTimeMinutes} {Constant.Command_Where} {Column_Username} = '{Username}'";
|
return $"{Constant.Command_Update} {TableName} {Constant.Command_Set} {Column_GameTime} = {Column_GameTime} + {GameTimeMinutes} {Constant.Command_Where} {Column_Username} = '{Username}'";
|
||||||
|
|||||||
@ -53,7 +53,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = _Socket?.Send(SocketMessageType.Disconnect, "") == SocketResult.Success;
|
result = _Socket?.Send(SocketMessageType.RunTime_Disconnect, "") == SocketResult.Success;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -196,15 +196,15 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
result = type;
|
result = type;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case SocketMessageType.Connect:
|
case SocketMessageType.RunTime_Connect:
|
||||||
if (!SocketHandler_Connect(ServerMessage)) return SocketMessageType.Unknown;
|
if (!SocketHandler_Connect(ServerMessage)) return SocketMessageType.Unknown;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SocketMessageType.Disconnect:
|
case SocketMessageType.RunTime_Disconnect:
|
||||||
SocketHandler_Disconnect(ServerMessage);
|
SocketHandler_Disconnect(ServerMessage);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SocketMessageType.HeartBeat:
|
case SocketMessageType.RunTime_HeartBeat:
|
||||||
if (_Socket != null && _Socket.Connected)
|
if (_Socket != null && _Socket.Connected)
|
||||||
{
|
{
|
||||||
SocketHandler_HeartBeat(ServerMessage);
|
SocketHandler_HeartBeat(ServerMessage);
|
||||||
|
|||||||
@ -257,24 +257,24 @@ namespace Milimoe.FunGame.Core.Service
|
|||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
SocketMessageType.DataRequest => SocketSet.DataRequest,
|
SocketMessageType.DataRequest => SocketSet.DataRequest,
|
||||||
SocketMessageType.Connect => SocketSet.Connect,
|
SocketMessageType.RunTime_Connect => SocketSet.RunTime_Connect,
|
||||||
SocketMessageType.GetNotice => SocketSet.GetNotice,
|
SocketMessageType.RunTime_Reg => SocketSet.RunTime_Reg,
|
||||||
SocketMessageType.Login => SocketSet.Login,
|
SocketMessageType.RunTime_CheckReg => SocketSet.RunTime_CheckReg,
|
||||||
SocketMessageType.CheckLogin => SocketSet.CheckLogin,
|
SocketMessageType.RunTime_Login => SocketSet.RunTime_Login,
|
||||||
SocketMessageType.Logout => SocketSet.Logout,
|
SocketMessageType.RunTime_CheckLogin => SocketSet.RunTime_CheckLogin,
|
||||||
SocketMessageType.Disconnect => SocketSet.Disconnect,
|
SocketMessageType.RunTime_Logout => SocketSet.RunTime_Logout,
|
||||||
SocketMessageType.HeartBeat => SocketSet.HeartBeat,
|
SocketMessageType.RunTime_Disconnect => SocketSet.RunTime_Disconnect,
|
||||||
SocketMessageType.IntoRoom => SocketSet.IntoRoom,
|
SocketMessageType.RunTime_HeartBeat => SocketSet.RunTime_HeartBeat,
|
||||||
SocketMessageType.QuitRoom => SocketSet.QuitRoom,
|
SocketMessageType.Main_GetNotice => SocketSet.Main_GetNotice,
|
||||||
SocketMessageType.Chat => SocketSet.Chat,
|
SocketMessageType.Main_IntoRoom => SocketSet.Main_IntoRoom,
|
||||||
SocketMessageType.Reg => SocketSet.Reg,
|
SocketMessageType.Main_QuitRoom => SocketSet.Main_QuitRoom,
|
||||||
SocketMessageType.CheckReg => SocketSet.CheckReg,
|
SocketMessageType.Main_Chat => SocketSet.Main_Chat,
|
||||||
SocketMessageType.CreateRoom => SocketSet.CreateRoom,
|
SocketMessageType.Main_CreateRoom => SocketSet.Main_CreateRoom,
|
||||||
SocketMessageType.UpdateRoom => SocketSet.UpdateRoom,
|
SocketMessageType.Main_UpdateRoom => SocketSet.Main_UpdateRoom,
|
||||||
SocketMessageType.ChangeRoomSetting => SocketSet.ChangeRoomSetting,
|
SocketMessageType.Main_MatchRoom => SocketSet.Main_MatchRoom,
|
||||||
SocketMessageType.MatchRoom => SocketSet.MatchRoom,
|
SocketMessageType.Room_ChangeRoomSetting => SocketSet.Room_ChangeRoomSetting,
|
||||||
SocketMessageType.UpdateRoomMaster => SocketSet.UpdateRoomMaster,
|
SocketMessageType.Room_UpdateRoomMaster => SocketSet.Room_UpdateRoomMaster,
|
||||||
SocketMessageType.GetRoomPlayerCount => SocketSet.GetRoomPlayerCount,
|
SocketMessageType.Room_GetRoomPlayerCount => SocketSet.Room_GetRoomPlayerCount,
|
||||||
_ => SocketSet.Unknown,
|
_ => SocketSet.Unknown,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user