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.Constant;
|
||||
using Milimoe.FunGame.Core.Library.Exception;
|
||||
using Milimoe.FunGame.Core.Service;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Transmittal
|
||||
{
|
||||
@ -88,7 +87,7 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
||||
/// <returns></returns>
|
||||
public T? GetResult<T>(string key)
|
||||
{
|
||||
return JsonManager.GetObject<T>(Worker.ResultData, key);
|
||||
return GetHashtableJsonObject<T>(Worker.ResultData, key);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
SocketObject result = SocketManager.Receive();
|
||||
if (result.SocketType == SocketMessageType.HeartBeat)
|
||||
if (result.SocketType == SocketMessageType.RunTime_HeartBeat)
|
||||
{
|
||||
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
||||
_HeartBeatFaileds = 0;
|
||||
@ -79,7 +79,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
SocketObject[] result = SocketManager.ReceiveArray();
|
||||
foreach (SocketObject obj in result)
|
||||
{
|
||||
if (obj.SocketType == SocketMessageType.HeartBeat)
|
||||
if (obj.SocketType == SocketMessageType.RunTime_HeartBeat)
|
||||
{
|
||||
if (WaitHeartBeatReply != null && !WaitHeartBeatReply.IsCompleted) WaitHeartBeatReply.Wait(1);
|
||||
_HeartBeatFaileds = 0;
|
||||
@ -155,7 +155,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
{
|
||||
if (!SendingHeartBeat) _SendingHeartBeat= true;
|
||||
// 发送心跳包
|
||||
if (Send(SocketMessageType.HeartBeat) == SocketResult.Success)
|
||||
if (Send(SocketMessageType.RunTime_HeartBeat) == SocketResult.Success)
|
||||
{
|
||||
WaitHeartBeatReply = Task.Run(() =>
|
||||
{
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
/**
|
||||
* 此文件用于保存字符串常量(String Set)
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public class InterfaceSet
|
||||
{
|
||||
@ -31,24 +34,42 @@
|
||||
public const string Socket = "Socket";
|
||||
public const string Unknown = "Unknown";
|
||||
public const string DataRequest = "DataRequest";
|
||||
public const string Connect = "Connect";
|
||||
public const string GetNotice = "GetNotice";
|
||||
public const string Login = "Login";
|
||||
public const string CheckLogin = "CheckLogin";
|
||||
public const string Logout = "Logout";
|
||||
public const string Disconnect = "Disconnect";
|
||||
public const string HeartBeat = "HeartBeat";
|
||||
public const string IntoRoom = "IntoRoom";
|
||||
public const string QuitRoom = "QuitRoom";
|
||||
public const string Chat = "Chat";
|
||||
public const string Reg = "Reg";
|
||||
public const string CheckReg = "CheckReg";
|
||||
public const string CreateRoom = "CreateRoom";
|
||||
public const string UpdateRoom = "UpdateRoom";
|
||||
public const string ChangeRoomSetting = "ChangeRoomSetting";
|
||||
public const string MatchRoom = "MatchRoom";
|
||||
public const string UpdateRoomMaster = "UpdateRoomMaster";
|
||||
public const string GetRoomPlayerCount = "GetRoomPlayerCount";
|
||||
public const string RunTime_Connect = "RunTime_Connect";
|
||||
public const string RunTime_Reg = "RunTime_Reg";
|
||||
public const string RunTime_CheckReg = "RunTime_CheckReg";
|
||||
public const string RunTime_Login = "RunTime_Login";
|
||||
public const string RunTime_CheckLogin = "RunTime_CheckLogin";
|
||||
public const string RunTime_Logout = "RunTime_Logout";
|
||||
public const string RunTime_Disconnect = "RunTime_Disconnect";
|
||||
public const string RunTime_HeartBeat = "RunTime_HeartBeat";
|
||||
public const string Main_GetNotice = "Main_GetNotice";
|
||||
public const string Main_IntoRoom = "Main_IntoRoom";
|
||||
public const string Main_QuitRoom = "Main_QuitRoom";
|
||||
public const string Main_Chat = "Main_Chat";
|
||||
public const string Main_CreateRoom = "Main_CreateRoom";
|
||||
public const string Main_UpdateRoom = "Main_UpdateRoom";
|
||||
public const string Main_MatchRoom = "Main_MatchRoom";
|
||||
public const string Room_ChangeRoomSetting = "Room_ChangeRoomSetting";
|
||||
public const string Room_UpdateRoomMaster = "Room_UpdateRoomMaster";
|
||||
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
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
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_Api = "FunGame Core Api";
|
||||
@ -33,7 +33,7 @@
|
||||
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 Milimoe.FunGame.Core.Entity;
|
||||
|
||||
/**
|
||||
* 此文件保存常用的对象常量
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public class General
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
/**
|
||||
* 此文件保存Method(方法)的枚举
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public enum InterfaceMethod
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
/**
|
||||
* 此文件保存Result(结果)的枚举
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public enum MessageResult
|
||||
{
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
/**
|
||||
* 此文件保存State(状态)的枚举
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public enum StartMatchState
|
||||
{
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
/**
|
||||
* 此文件保存Type(类型)的枚举
|
||||
*/
|
||||
namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
public enum FormType
|
||||
{
|
||||
@ -56,37 +59,41 @@
|
||||
{
|
||||
Unknown,
|
||||
DataRequest,
|
||||
Connect,
|
||||
GetNotice,
|
||||
Login,
|
||||
CheckLogin,
|
||||
Logout,
|
||||
ForceLogout,
|
||||
Disconnect,
|
||||
HeartBeat,
|
||||
IntoRoom,
|
||||
QuitRoom,
|
||||
Chat,
|
||||
Reg,
|
||||
CheckReg,
|
||||
CreateRoom,
|
||||
UpdateRoom,
|
||||
ChangeRoomSetting,
|
||||
MatchRoom,
|
||||
UpdateRoomMaster,
|
||||
GetRoomPlayerCount
|
||||
RunTime_Connect,
|
||||
RunTime_Reg,
|
||||
RunTime_CheckReg,
|
||||
RunTime_Login,
|
||||
RunTime_CheckLogin,
|
||||
RunTime_Logout,
|
||||
RunTime_ForceLogout,
|
||||
RunTime_Disconnect,
|
||||
RunTime_HeartBeat,
|
||||
Main_GetNotice,
|
||||
Main_IntoRoom,
|
||||
Main_QuitRoom,
|
||||
Main_Chat,
|
||||
Main_CreateRoom,
|
||||
Main_UpdateRoom,
|
||||
Main_MatchRoom,
|
||||
Room_ChangeRoomSetting,
|
||||
Room_UpdateRoomMaster,
|
||||
Room_GetRoomPlayerCount
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 需要同步更新Milimoe.FunGame.Core.Library.Constant.DataRequestSet
|
||||
/// </summary>
|
||||
public enum DataRequestType
|
||||
{
|
||||
UnKnown,
|
||||
GetNotice,
|
||||
GetRegVerifyCode,
|
||||
CreateRoom,
|
||||
UpdateRoom,
|
||||
GetRoomSettings,
|
||||
GetRoomPlayerCount,
|
||||
GetFindPasswordVerifyCode
|
||||
Main_GetNotice,
|
||||
Main_CreateRoom,
|
||||
Main_UpdateRoom,
|
||||
Reg_GetRegVerifyCode,
|
||||
Login_GetFindPasswordVerifyCode,
|
||||
Login_UpdatePassword,
|
||||
Room_GetRoomSettings,
|
||||
Room_GetRoomPlayerCount
|
||||
}
|
||||
|
||||
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}'";
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
result = _Socket?.Send(SocketMessageType.Disconnect, "") == SocketResult.Success;
|
||||
result = _Socket?.Send(SocketMessageType.RunTime_Disconnect, "") == SocketResult.Success;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -196,15 +196,15 @@ namespace Milimoe.FunGame.Core.Model
|
||||
result = type;
|
||||
switch (type)
|
||||
{
|
||||
case SocketMessageType.Connect:
|
||||
case SocketMessageType.RunTime_Connect:
|
||||
if (!SocketHandler_Connect(ServerMessage)) return SocketMessageType.Unknown;
|
||||
break;
|
||||
|
||||
case SocketMessageType.Disconnect:
|
||||
case SocketMessageType.RunTime_Disconnect:
|
||||
SocketHandler_Disconnect(ServerMessage);
|
||||
break;
|
||||
|
||||
case SocketMessageType.HeartBeat:
|
||||
case SocketMessageType.RunTime_HeartBeat:
|
||||
if (_Socket != null && _Socket.Connected)
|
||||
{
|
||||
SocketHandler_HeartBeat(ServerMessage);
|
||||
|
||||
@ -257,24 +257,24 @@ namespace Milimoe.FunGame.Core.Service
|
||||
return type switch
|
||||
{
|
||||
SocketMessageType.DataRequest => SocketSet.DataRequest,
|
||||
SocketMessageType.Connect => SocketSet.Connect,
|
||||
SocketMessageType.GetNotice => SocketSet.GetNotice,
|
||||
SocketMessageType.Login => SocketSet.Login,
|
||||
SocketMessageType.CheckLogin => SocketSet.CheckLogin,
|
||||
SocketMessageType.Logout => SocketSet.Logout,
|
||||
SocketMessageType.Disconnect => SocketSet.Disconnect,
|
||||
SocketMessageType.HeartBeat => SocketSet.HeartBeat,
|
||||
SocketMessageType.IntoRoom => SocketSet.IntoRoom,
|
||||
SocketMessageType.QuitRoom => SocketSet.QuitRoom,
|
||||
SocketMessageType.Chat => SocketSet.Chat,
|
||||
SocketMessageType.Reg => SocketSet.Reg,
|
||||
SocketMessageType.CheckReg => SocketSet.CheckReg,
|
||||
SocketMessageType.CreateRoom => SocketSet.CreateRoom,
|
||||
SocketMessageType.UpdateRoom => SocketSet.UpdateRoom,
|
||||
SocketMessageType.ChangeRoomSetting => SocketSet.ChangeRoomSetting,
|
||||
SocketMessageType.MatchRoom => SocketSet.MatchRoom,
|
||||
SocketMessageType.UpdateRoomMaster => SocketSet.UpdateRoomMaster,
|
||||
SocketMessageType.GetRoomPlayerCount => SocketSet.GetRoomPlayerCount,
|
||||
SocketMessageType.RunTime_Connect => SocketSet.RunTime_Connect,
|
||||
SocketMessageType.RunTime_Reg => SocketSet.RunTime_Reg,
|
||||
SocketMessageType.RunTime_CheckReg => SocketSet.RunTime_CheckReg,
|
||||
SocketMessageType.RunTime_Login => SocketSet.RunTime_Login,
|
||||
SocketMessageType.RunTime_CheckLogin => SocketSet.RunTime_CheckLogin,
|
||||
SocketMessageType.RunTime_Logout => SocketSet.RunTime_Logout,
|
||||
SocketMessageType.RunTime_Disconnect => SocketSet.RunTime_Disconnect,
|
||||
SocketMessageType.RunTime_HeartBeat => SocketSet.RunTime_HeartBeat,
|
||||
SocketMessageType.Main_GetNotice => SocketSet.Main_GetNotice,
|
||||
SocketMessageType.Main_IntoRoom => SocketSet.Main_IntoRoom,
|
||||
SocketMessageType.Main_QuitRoom => SocketSet.Main_QuitRoom,
|
||||
SocketMessageType.Main_Chat => SocketSet.Main_Chat,
|
||||
SocketMessageType.Main_CreateRoom => SocketSet.Main_CreateRoom,
|
||||
SocketMessageType.Main_UpdateRoom => SocketSet.Main_UpdateRoom,
|
||||
SocketMessageType.Main_MatchRoom => SocketSet.Main_MatchRoom,
|
||||
SocketMessageType.Room_ChangeRoomSetting => SocketSet.Room_ChangeRoomSetting,
|
||||
SocketMessageType.Room_UpdateRoomMaster => SocketSet.Room_UpdateRoomMaster,
|
||||
SocketMessageType.Room_GetRoomPlayerCount => SocketSet.Room_GetRoomPlayerCount,
|
||||
_ => SocketSet.Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user