mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-22 04:59:34 +08:00
修改架构 第二部分 (#16)
* 移除多余实现 * 修改方法名 * 更新连接服务器的逻辑 * 添加异常处理 * 修改架构之Login * 修复IntoRoom Bug * 修复ForceLogOut Bug * 修复LogOut Bug * 修复CreateRoom QuitRoom IntoRoom * 断开连接后,应该关闭Socket连接 * 修复Reg Main Bug
This commit is contained in:
parent
a72881d15f
commit
7061996177
@ -26,20 +26,23 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
string msg = "";
|
string msg = "";
|
||||||
LoginEventArgs args = new(username, password, autokey);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
password = password.Encrypt(username);
|
||||||
|
LoginEventArgs args = new(username, password, autokey);
|
||||||
|
|
||||||
if (OnBeforeLoginEvent(args))
|
if (OnBeforeLoginEvent(args))
|
||||||
{
|
{
|
||||||
DataRequest request = RunTime.NewLongRunningDataRequest(DataRequestType.RunTime_Login);
|
DataRequest request = RunTime.NewLongRunningDataRequest(DataRequestType.Login_Login);
|
||||||
request.AddRequestData("username", username);
|
request.AddRequestData("username", username);
|
||||||
request.AddRequestData("password", password);
|
request.AddRequestData("password", password);
|
||||||
request.AddRequestData("autokey", autokey);
|
request.AddRequestData("autokey", autokey);
|
||||||
|
request.AddRequestData("key", Guid.Empty);
|
||||||
await request.SendRequestAsync();
|
await request.SendRequestAsync();
|
||||||
if (request.Result == RequestResult.Success)
|
if (request.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
Guid key = request.GetResult<Guid>("checkloginkey");
|
Guid key = request.GetResult<Guid>("key");
|
||||||
msg = request.GetResult<string>("msg") ?? "";
|
msg = request.GetResult<string>("msg") ?? "";
|
||||||
if (msg != "")
|
if (msg != "")
|
||||||
{
|
{
|
||||||
@ -47,7 +50,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
else if (key != Guid.Empty)
|
else if (key != Guid.Empty)
|
||||||
{
|
{
|
||||||
request.AddRequestData("checkloginkey", key);
|
request.AddRequestData("key", key);
|
||||||
await request.SendRequestAsync();
|
await request.SendRequestAsync();
|
||||||
if (request.Result == RequestResult.Success)
|
if (request.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
@ -62,6 +65,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
if (user.Id != 0)
|
if (user.Id != 0)
|
||||||
{
|
{
|
||||||
// 创建User对象并返回到Main
|
// 创建User对象并返回到Main
|
||||||
|
RunTime.Session.LoginKey = key;
|
||||||
RunTime.Main?.UpdateUI(MainInvokeType.SetUser, user);
|
RunTime.Main?.UpdateUI(MainInvokeType.SetUser, user);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
@ -71,11 +75,6 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
request.Dispose();
|
request.Dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
RunTime.WritelnSystemInfo(e.GetErrorInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result && msg == "")
|
if (!result && msg == "")
|
||||||
{
|
{
|
||||||
@ -83,6 +82,11 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
OnAfterLoginEvent(result, args);
|
OnAfterLoginEvent(result, args);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RunTime.WritelnSystemInfo(e.GetErrorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
using Milimoe.FunGame.Core.Controller;
|
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
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.Model;
|
using Milimoe.FunGame.Core.Model;
|
||||||
@ -11,7 +9,7 @@ using Milimoe.FunGame.Desktop.UI;
|
|||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Controller
|
namespace Milimoe.FunGame.Desktop.Controller
|
||||||
{
|
{
|
||||||
public class MainController : SocketHandlerController
|
public class MainController
|
||||||
{
|
{
|
||||||
private readonly Main Main;
|
private readonly Main Main;
|
||||||
private readonly Session Usercfg = RunTime.Session;
|
private readonly Session Usercfg = RunTime.Session;
|
||||||
@ -22,7 +20,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
private readonly DataRequest IntoRoomRequest;
|
private readonly DataRequest IntoRoomRequest;
|
||||||
private readonly DataRequest QuitRoomRequest;
|
private readonly DataRequest QuitRoomRequest;
|
||||||
|
|
||||||
public MainController(Main main) : base(RunTime.Socket)
|
public MainController(Main main)
|
||||||
{
|
{
|
||||||
Main = main;
|
Main = main;
|
||||||
ChatRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_Chat);
|
ChatRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_Chat);
|
||||||
@ -31,11 +29,20 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
UpdateRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_UpdateRoom);
|
UpdateRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_UpdateRoom);
|
||||||
IntoRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_IntoRoom);
|
IntoRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_IntoRoom);
|
||||||
QuitRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_QuitRoom);
|
QuitRoomRequest = RunTime.NewLongRunningDataRequest(DataRequestType.Main_QuitRoom);
|
||||||
Disposed += MainController_Disposed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 公开方法
|
#region 公开方法
|
||||||
|
|
||||||
|
public void MainController_Disposed()
|
||||||
|
{
|
||||||
|
ChatRequest.Dispose();
|
||||||
|
CreateRoomRequest.Dispose();
|
||||||
|
GetRoomPlayerCountRequest.Dispose();
|
||||||
|
UpdateRoomRequest.Dispose();
|
||||||
|
IntoRoomRequest.Dispose();
|
||||||
|
QuitRoomRequest.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> LogOutAsync()
|
public async Task<bool> LogOutAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -44,7 +51,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
if (Usercfg.LoginKey != Guid.Empty)
|
if (Usercfg.LoginKey != Guid.Empty)
|
||||||
{
|
{
|
||||||
DataRequest request = RunTime.NewDataRequest(DataRequestType.RunTime_Logout);
|
DataRequest request = RunTime.NewDataRequest(DataRequestType.RunTime_Logout);
|
||||||
request.AddRequestData("loginkey", Usercfg.LoginKey);
|
request.AddRequestData("key", Usercfg.LoginKey);
|
||||||
await request.SendRequestAsync();
|
await request.SendRequestAsync();
|
||||||
if (request.Result == RequestResult.Success)
|
if (request.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
@ -74,31 +81,17 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string rid = room.Roomid;
|
IntoRoomRequest.AddRequestData("roomid", room.Roomid);
|
||||||
IntoRoomRequest.AddRequestData("room", rid);
|
|
||||||
await IntoRoomRequest.SendRequestAsync();
|
await IntoRoomRequest.SendRequestAsync();
|
||||||
if (IntoRoomRequest.Result == RequestResult.Success)
|
if (IntoRoomRequest.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
string roomid = IntoRoomRequest.GetResult<string>("roomid") ?? "";
|
return IntoRoomRequest.GetResult<bool>("result");
|
||||||
if (rid == roomid)
|
|
||||||
{
|
|
||||||
// 先确认是否是加入的房间,防止服务端返回错误的房间
|
|
||||||
if (roomid.Trim() != "" && roomid == "-1")
|
|
||||||
{
|
|
||||||
Main.GetMessage($"已连接至公共聊天室。");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Usercfg.InRoom = room;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new CanNotIntoRoomException();
|
throw new CanNotIntoRoomException();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,14 +106,14 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
await UpdateRoomRequest.SendRequestAsync();
|
await UpdateRoomRequest.SendRequestAsync();
|
||||||
if (UpdateRoomRequest.Result == RequestResult.Success)
|
if (UpdateRoomRequest.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
list = UpdateRoomRequest.GetResult<List<Room>>("roomid") ?? new();
|
list = UpdateRoomRequest.GetResult<List<Room>>("rooms") ?? new();
|
||||||
Main.UpdateUI(MainInvokeType.UpdateRoom, list);
|
Main.UpdateUI(MainInvokeType.UpdateRoom, list);
|
||||||
}
|
}
|
||||||
else throw new CanNotIntoRoomException();
|
else throw new CanNotIntoRoomException();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -136,7 +129,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,11 +152,11 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new CanNotIntoRoomException();
|
throw new QuitRoomException();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +168,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
CreateRoomRequest.AddRequestData("roomtype", RoomType);
|
CreateRoomRequest.AddRequestData("roomtype", RoomType);
|
||||||
CreateRoomRequest.AddRequestData("user", Usercfg.LoginUser);
|
CreateRoomRequest.AddRequestData("master", Usercfg.LoginUser);
|
||||||
CreateRoomRequest.AddRequestData("password", Password);
|
CreateRoomRequest.AddRequestData("password", Password);
|
||||||
await CreateRoomRequest.SendRequestAsync();
|
await CreateRoomRequest.SendRequestAsync();
|
||||||
if (CreateRoomRequest.Result == RequestResult.Success)
|
if (CreateRoomRequest.Result == RequestResult.Success)
|
||||||
@ -185,7 +178,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
return roomid;
|
return roomid;
|
||||||
@ -205,75 +198,11 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Main.GetMessage(e.GetErrorInfo());
|
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SocketHandler(SocketObject SocketObject)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (SocketObject.SocketType == SocketMessageType.HeartBeat)
|
|
||||||
{
|
|
||||||
// 心跳包单独处理
|
|
||||||
if ((RunTime.Socket?.Connected ?? false) && Usercfg.LoginUser.Id != 0)
|
|
||||||
Main.UpdateUI(MainInvokeType.SetGreenAndPing);
|
|
||||||
}
|
|
||||||
else if (SocketObject.SocketType == SocketMessageType.ForceLogout)
|
|
||||||
{
|
|
||||||
// 服务器强制下线登录
|
|
||||||
Guid key = Guid.Empty;
|
|
||||||
string msg = "";
|
|
||||||
if (SocketObject.Length > 0) key = SocketObject.GetParam<Guid>(0);
|
|
||||||
if (SocketObject.Length > 1) msg = SocketObject.GetParam<string>(1) ?? "";
|
|
||||||
if (key == Usercfg.LoginKey)
|
|
||||||
{
|
|
||||||
Usercfg.LoginKey = Guid.Empty;
|
|
||||||
Main.UpdateUI(MainInvokeType.LogOut, msg ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (SocketObject.SocketType == SocketMessageType.Chat)
|
|
||||||
{
|
|
||||||
// 收到房间聊天信息
|
|
||||||
string user = "", msg = "";
|
|
||||||
if (SocketObject.Length > 0) user = SocketObject.GetParam<string>(0) ?? "";
|
|
||||||
if (SocketObject.Length > 1) msg = SocketObject.GetParam<string>(1) ?? "";
|
|
||||||
if (user != Usercfg.LoginUserName)
|
|
||||||
{
|
|
||||||
Main.GetMessage(msg, TimeType.None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (SocketObject.SocketType == SocketMessageType.UpdateRoomMaster)
|
|
||||||
{
|
|
||||||
// 收到房间更换房主的信息
|
|
||||||
User user = General.UnknownUserInstance;
|
|
||||||
Room room = General.HallInstance;
|
|
||||||
if (SocketObject.Length > 0) user = SocketObject.GetParam<User>(0) ?? General.UnknownUserInstance;
|
|
||||||
if (SocketObject.Length > 1) room = SocketObject.GetParam<Room>(1) ?? General.HallInstance;
|
|
||||||
if (room.Roomid != "-1" && room.Roomid == Usercfg.InRoom.Roomid) Main.UpdateUI(MainInvokeType.UpdateRoomMaster, room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
RunTime.Controller?.Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 私有方法
|
|
||||||
|
|
||||||
private void MainController_Disposed()
|
|
||||||
{
|
|
||||||
ChatRequest.Dispose();
|
|
||||||
CreateRoomRequest.Dispose();
|
|
||||||
GetRoomPlayerCountRequest.Dispose();
|
|
||||||
UpdateRoomRequest.Dispose();
|
|
||||||
IntoRoomRequest.Dispose();
|
|
||||||
QuitRoomRequest.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
|
||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Library.Component;
|
using Milimoe.FunGame.Desktop.Library.Component;
|
||||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
|
using Milimoe.FunGame.Desktop.UI;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Controller
|
namespace Milimoe.FunGame.Desktop.Controller
|
||||||
{
|
{
|
||||||
@ -37,6 +37,10 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
if (request.Result == RequestResult.Success)
|
if (request.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
RegInvokeType InvokeType = request.GetResult<RegInvokeType>("type");
|
RegInvokeType InvokeType = request.GetResult<RegInvokeType>("type");
|
||||||
|
switch (InvokeType)
|
||||||
|
{
|
||||||
|
case RegInvokeType.InputVerifyCode:
|
||||||
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
string verifycode = ShowMessage.InputMessageCancel("请输入注册邮件中的6位数字验证码", "注册验证码", out MessageResult cancel);
|
string verifycode = ShowMessage.InputMessageCancel("请输入注册邮件中的6位数字验证码", "注册验证码", out MessageResult cancel);
|
||||||
@ -46,14 +50,30 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
await request.SendRequestAsync();
|
await request.SendRequestAsync();
|
||||||
if (request.Result == RequestResult.Success)
|
if (request.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
bool success = request.GetResult<bool>("success");
|
result = request.GetResult<bool>("success");
|
||||||
string msg = request.GetResult<string>("msg") ?? "";
|
string msg = request.GetResult<string>("msg") ?? "";
|
||||||
if (msg != "") ShowMessage.Message(msg, "注册结果");
|
if (msg != "") ShowMessage.Message(msg, "注册结果");
|
||||||
if (success) return success;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RegInvokeType.DuplicateUserName:
|
||||||
|
{
|
||||||
|
result = request.GetResult<bool>("success");
|
||||||
|
string msg = request.GetResult<string>("msg") ?? "";
|
||||||
|
ShowMessage.Message(msg, "注册结果");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RegInvokeType.DuplicateEmail:
|
||||||
|
{
|
||||||
|
result = request.GetResult<bool>("success");
|
||||||
|
string msg = request.GetResult<string>("msg") ?? "";
|
||||||
|
ShowMessage.Message(msg, "注册结果");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
request.Dispose();
|
request.Dispose();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
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;
|
||||||
@ -34,24 +34,12 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ConnectResult Connect()
|
public override bool BeforeConnect(ref string ip, ref int port)
|
||||||
{
|
|
||||||
if (RunTime.Session.Server_IP == "" || RunTime.Session.Server_Port <= 0)
|
|
||||||
{
|
|
||||||
(RunTime.Session.Server_IP, RunTime.Session.Server_Port) = GetServerAddress();
|
|
||||||
if (RunTime.Session.Server_IP == "" || RunTime.Session.Server_Port <= 0)
|
|
||||||
{
|
|
||||||
Main.ShowMessage(ShowMessageType.Error, "查找可用的服务器失败!");
|
|
||||||
return ConnectResult.FindServerFailed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (Config.FunGame_isRetrying)
|
if (Config.FunGame_isRetrying)
|
||||||
{
|
{
|
||||||
Main.GetMessage("正在连接服务器,请耐心等待。");
|
Main.GetMessage("正在连接服务器,请耐心等待。");
|
||||||
Config.FunGame_isRetrying = false;
|
return false;
|
||||||
return ConnectResult.CanNotConnect;
|
|
||||||
}
|
}
|
||||||
if (!Config.FunGame_isConnected)
|
if (!Config.FunGame_isConnected)
|
||||||
{
|
{
|
||||||
@ -63,83 +51,54 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
{
|
{
|
||||||
throw new CanNotConnectException();
|
throw new CanNotConnectException();
|
||||||
}
|
}
|
||||||
// 与服务器建立连接
|
|
||||||
Socket?.Close();
|
|
||||||
Config.FunGame_isRetrying = true;
|
Config.FunGame_isRetrying = true;
|
||||||
_Socket = Socket.Connect(RunTime.Session.Server_IP, RunTime.Session.Server_Port);
|
// 如果服务器地址为空需要获取一次地址
|
||||||
if (Socket != null && Socket.Connected)
|
if (ip == "" || port <= 0)
|
||||||
{
|
{
|
||||||
// 设置可复用Socket
|
(ip, port) = GetServerAddress();
|
||||||
RunTime.Socket = Socket;
|
RunTime.Session.Server_IP = ip;
|
||||||
// 发送连接请求
|
RunTime.Session.Server_Port = port;
|
||||||
DataRequest request = RunTime.NewDataRequest(DataRequestType.RunTime_Connect);
|
|
||||||
request.SendRequest();
|
|
||||||
if (request.Result == RequestResult.Success)
|
|
||||||
{
|
|
||||||
bool success = request.GetResult<bool>("success");
|
|
||||||
string msg = request.GetResult<string>("msg") ?? "";
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
// 服务器拒绝连接
|
|
||||||
if (msg != "")
|
|
||||||
{
|
|
||||||
Main.GetMessage(msg);
|
|
||||||
Main.ShowMessage(ShowMessageType.Error, msg);
|
|
||||||
}
|
}
|
||||||
return ConnectResult.ConnectFailed;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Main.GetMessage("已连接至服务器,请勿重复连接。");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AfterConnect(object[] ConnectArgs)
|
||||||
|
{
|
||||||
|
Config.FunGame_isRetrying = false;
|
||||||
|
|
||||||
|
ConnectResult result = (ConnectResult)ConnectArgs[0];
|
||||||
|
string msg = (string)ConnectArgs[1];
|
||||||
|
string servername = (string)ConnectArgs[2];
|
||||||
|
string notice = (string)ConnectArgs[3];
|
||||||
|
|
||||||
if (msg != "")
|
if (msg != "")
|
||||||
{
|
{
|
||||||
Main.GetMessage(msg);
|
Main.GetMessage(msg);
|
||||||
|
if (result != ConnectResult.Success) Main.ShowMessage(ShowMessageType.Error, msg);
|
||||||
}
|
}
|
||||||
Guid token = request.GetResult<Guid>("token");
|
|
||||||
string servername = request.GetResult<string>("servername") ?? "";
|
if (result == ConnectResult.Success)
|
||||||
string notice = request.GetResult<string>("notice") ?? "";
|
{
|
||||||
|
// 设置可复用Socket
|
||||||
|
RunTime.Socket = Socket;
|
||||||
Config.FunGame_ServerName = servername;
|
Config.FunGame_ServerName = servername;
|
||||||
Config.FunGame_Notice = notice;
|
Config.FunGame_Notice = notice;
|
||||||
Socket!.Token = token;
|
Usercfg.SocketToken = Socket?.Token ?? Guid.Empty;
|
||||||
Usercfg.SocketToken = token;
|
|
||||||
Main.GetMessage($"已连接服务器:{servername}。\n\n********** 服务器公告 **********\n\n{notice}\n\n");
|
Main.GetMessage($"已连接服务器:{servername}。\n\n********** 服务器公告 **********\n\n{notice}\n\n");
|
||||||
// 设置等待登录的黄灯
|
// 设置等待登录的黄灯
|
||||||
Main.UpdateUI(MainInvokeType.WaitLoginAndSetYellow);
|
Main.UpdateUI(MainInvokeType.WaitLoginAndSetYellow);
|
||||||
Main.GetMessage("连接服务器成功,请登录账号以体验FunGame。");
|
Main.GetMessage("连接服务器成功,请登录账号以体验FunGame。");
|
||||||
Main.UpdateUI(MainInvokeType.Connected);
|
Main.UpdateUI(MainInvokeType.Connected);
|
||||||
StartReceiving();
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (_IsReceiving)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return ConnectResult.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Config.FunGame_isRetrying = false;
|
|
||||||
Socket.Close();
|
|
||||||
return ConnectResult.ConnectFailed;
|
|
||||||
}
|
|
||||||
Socket?.Close();
|
|
||||||
Config.FunGame_isRetrying = false;
|
|
||||||
throw new CanNotConnectException();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Main.GetMessage("已连接至服务器,请勿重复连接。");
|
|
||||||
return ConnectResult.CanNotConnect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Main.GetMessage(e.GetErrorInfo(), TimeType.None);
|
|
||||||
Main.UpdateUI(MainInvokeType.SetRed);
|
Main.UpdateUI(MainInvokeType.SetRed);
|
||||||
Config.FunGame_isRetrying = false;
|
|
||||||
return ConnectResult.ConnectFailed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +116,9 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
|
|
||||||
protected override void SocketHandler_Disconnect(SocketObject ServerMessage)
|
protected override void SocketHandler_Disconnect(SocketObject ServerMessage)
|
||||||
{
|
{
|
||||||
|
// 断开与服务器的连接
|
||||||
string msg = "";
|
string msg = "";
|
||||||
if (ServerMessage.Parameters.Length > 0) msg = ServerMessage.GetParam<string>(0)!;
|
if (ServerMessage.Parameters.Length > 0) msg = ServerMessage.GetParam<string>(0) ?? "";
|
||||||
Main.GetMessage(msg);
|
Main.GetMessage(msg);
|
||||||
Main.UpdateUI(MainInvokeType.Disconnect);
|
Main.UpdateUI(MainInvokeType.Disconnect);
|
||||||
Close();
|
Close();
|
||||||
@ -168,10 +128,40 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
|
|
||||||
protected override void SocketHandler_HeartBeat(SocketObject ServerMessage)
|
protected override void SocketHandler_HeartBeat(SocketObject ServerMessage)
|
||||||
{
|
{
|
||||||
|
// 收到心跳包时更新与服务器的连接延迟
|
||||||
if (Socket != null && Socket.Connected && Usercfg.LoginUser.Id != 0)
|
if (Socket != null && Socket.Connected && Usercfg.LoginUser.Id != 0)
|
||||||
{
|
{
|
||||||
Main.UpdateUI(MainInvokeType.SetGreenAndPing);
|
Main.UpdateUI(MainInvokeType.SetGreenAndPing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_ForceLogout(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
// 服务器强制下线登录
|
||||||
|
string msg = "";
|
||||||
|
if (ServerMessage.Length > 0) msg = ServerMessage.GetParam<string>(0) ?? "";
|
||||||
|
Usercfg.LoginKey = Guid.Empty;
|
||||||
|
Main.UpdateUI(MainInvokeType.LogOut, msg ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_Chat(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
// 收到房间聊天信息
|
||||||
|
string user = "", msg = "";
|
||||||
|
if (ServerMessage.Length > 0) user = ServerMessage.GetParam<string>(0) ?? "";
|
||||||
|
if (ServerMessage.Length > 1) msg = ServerMessage.GetParam<string>(1) ?? "";
|
||||||
|
if (user != Usercfg.LoginUserName)
|
||||||
|
{
|
||||||
|
Main.GetMessage(msg, TimeType.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_UpdateRoomMaster(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
// 收到房间更换房主的信息
|
||||||
|
Room room = General.HallInstance;
|
||||||
|
if (ServerMessage.Length > 0) room = ServerMessage.GetParam<Room>(0) ?? General.HallInstance;
|
||||||
|
if (room.Roomid != "-1" && room.Roomid == Usercfg.InRoom.Roomid) Main.UpdateUI(MainInvokeType.UpdateRoomMaster, room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.Library.Component
|
namespace Milimoe.FunGame.Desktop.Library.Component
|
||||||
{
|
{
|
||||||
@ -7,7 +8,6 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
private MessageResult MessageResult = MessageResult.Cancel;
|
private MessageResult MessageResult = MessageResult.Cancel;
|
||||||
private string InputResult = "";
|
private string InputResult = "";
|
||||||
private readonly int AutoClose = 0;
|
private readonly int AutoClose = 0;
|
||||||
private readonly Task? TaskAutoClose;
|
|
||||||
|
|
||||||
private const string TITLE_TIP = "提示";
|
private const string TITLE_TIP = "提示";
|
||||||
private const string TITLE_WARNING = "警告";
|
private const string TITLE_WARNING = "警告";
|
||||||
@ -113,17 +113,24 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
}
|
}
|
||||||
if (AutoClose > 0)
|
if (AutoClose > 0)
|
||||||
{
|
{
|
||||||
TaskAutoClose = Task.Factory.StartNew(() =>
|
TaskUtility.StartAndAwaitTask(async () =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(1);
|
|
||||||
string msg = MsgText.Text;
|
string msg = MsgText.Text;
|
||||||
int s = AutoClose;
|
int s = AutoClose;
|
||||||
BeginInvoke(() => ChangeSecond(msg, s));
|
await Task.Run(() =>
|
||||||
while (s > 0)
|
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
while (IsHandleCreated)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
BeginInvoke(() => ChangeSecond(msg, s));
|
||||||
|
while (!Disposing)
|
||||||
|
{
|
||||||
|
if (s > 0) await Task.Delay(1000);
|
||||||
|
else break;
|
||||||
s--;
|
s--;
|
||||||
if (IsHandleCreated) BeginInvoke(() => ChangeSecond(msg, s));
|
BeginInvoke(() => ChangeSecond(msg, s));
|
||||||
}
|
}
|
||||||
MessageResult = MessageResult.OK;
|
MessageResult = MessageResult.OK;
|
||||||
Close();
|
Close();
|
||||||
@ -147,7 +154,6 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
|||||||
BUTTON_RETRY => MessageResult.Retry,
|
BUTTON_RETRY => MessageResult.Retry,
|
||||||
_ => MessageResult.Cancel
|
_ => MessageResult.Cancel
|
||||||
};
|
};
|
||||||
TaskAutoClose?.Wait(1);
|
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
SetServerStatusLight((int)LightType.Red);
|
SetServerStatusLight((int)LightType.Red);
|
||||||
SetButtonEnableIfLogon(false, ClientState.WaitConnect);
|
SetButtonEnableIfLogon(false, ClientState.WaitConnect);
|
||||||
LogoutAccount();
|
LogoutAccount();
|
||||||
MainController?.Dispose();
|
MainController?.MainController_Disposed();
|
||||||
CloseConnectedWindows();
|
CloseConnectedWindows();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
SetServerStatusLight((int)LightType.Yellow);
|
SetServerStatusLight((int)LightType.Yellow);
|
||||||
SetButtonEnableIfLogon(false, ClientState.WaitConnect);
|
SetButtonEnableIfLogon(false, ClientState.WaitConnect);
|
||||||
LogoutAccount();
|
LogoutAccount();
|
||||||
MainController?.Dispose();
|
MainController?.MainController_Disposed();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MainInvokeType.LogIn:
|
case MainInvokeType.LogIn:
|
||||||
@ -239,7 +239,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
WritelnGameInfo(e.GetErrorInfo());
|
WritelnGameInfo(e.GetErrorInfo());
|
||||||
UpdateUI(MainInvokeType.SetRed);
|
UpdateUI(MainInvokeType.Disconnected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InvokeUpdateUI(action);
|
InvokeUpdateUI(action);
|
||||||
@ -743,10 +743,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
ShowMessage(ShowMessageType.Warning, "已在房间中,无法创建房间。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MainController != null)
|
string roomid = await InvokeController_CreateRoom(RoomType, Password);
|
||||||
{
|
if (MainController is not null && roomid != "-1")
|
||||||
string roomid = await MainController.CreateRoomAsync(RoomType, Password);
|
|
||||||
if (roomid != "" && roomid != "-1")
|
|
||||||
{
|
{
|
||||||
await MainController.UpdateRoomAsync();
|
await MainController.UpdateRoomAsync();
|
||||||
Room r = GetRoom(roomid);
|
Room r = GetRoom(roomid);
|
||||||
@ -758,7 +756,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
ShowMessage(ShowMessageType.General, "创建" + RoomType + "房间成功!\n房间号是 -> [ " + roomid + " ]", "创建成功");
|
ShowMessage(ShowMessageType.General, "创建" + RoomType + "房间成功!\n房间号是 -> [ " + roomid + " ]", "创建成功");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ShowMessage(ShowMessageType.General, "创建" + RoomType + "房间失败!", "创建失败");
|
ShowMessage(ShowMessageType.General, "创建" + RoomType + "房间失败!", "创建失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,14 +858,15 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 退出游戏时处理
|
/// 退出游戏时处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task ExitFunGame()
|
private void ExitFunGame()
|
||||||
|
{
|
||||||
|
TaskUtility.StartAndAwaitTask(() =>
|
||||||
{
|
{
|
||||||
if (ShowMessage(ShowMessageType.OKCancel, "你确定关闭游戏?", "退出") == MessageResult.OK)
|
if (ShowMessage(ShowMessageType.OKCancel, "你确定关闭游戏?", "退出") == MessageResult.OK)
|
||||||
{
|
{
|
||||||
if (MainController != null) await LogOut();
|
InvokeController_Disconnect();
|
||||||
RunTime.Controller?.Close();
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
}
|
||||||
|
}).OnCompleted(() => Environment.Exit(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -1208,7 +1206,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void Main_Disposed(object? sender, EventArgs e)
|
private void Main_Disposed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MainController?.Dispose();
|
MainController?.MainController_Disposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1380,7 +1378,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ErrorIPAddressType ErrorType = NetworkUtility.IsServerAddress(ip, port);
|
ErrorIPAddressType ErrorType = NetworkUtility.IsServerAddress(ip, port);
|
||||||
if (ErrorType == Core.Library.Constant.ErrorIPAddressType.None)
|
if (ErrorType == ErrorIPAddressType.None)
|
||||||
{
|
{
|
||||||
RunTime.Session.Server_IP = ip;
|
RunTime.Session.Server_IP = ip;
|
||||||
RunTime.Session.Server_Port = port;
|
RunTime.Session.Server_Port = port;
|
||||||
@ -1388,8 +1386,8 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
Config.FunGame_isAutoRetry = true;
|
Config.FunGame_isAutoRetry = true;
|
||||||
InvokeController_Connect();
|
InvokeController_Connect();
|
||||||
}
|
}
|
||||||
else if (ErrorType == Core.Library.Constant.ErrorIPAddressType.IsNotIP) ShowMessage(ShowMessageType.Error, "这不是一个IP地址!");
|
else if (ErrorType == ErrorIPAddressType.IsNotIP) ShowMessage(ShowMessageType.Error, "这不是一个IP地址!");
|
||||||
else if (ErrorType == Core.Library.Constant.ErrorIPAddressType.IsNotPort) ShowMessage(ShowMessageType.Error, "这不是一个端口号!\n正确范围:1~65535");
|
else if (ErrorType == ErrorIPAddressType.IsNotPort) ShowMessage(ShowMessageType.Error, "这不是一个端口号!\n正确范围:1~65535");
|
||||||
else ShowMessage(ShowMessageType.Error, "格式错误!\n这不是一个服务器地址。");
|
else ShowMessage(ShowMessageType.Error, "格式错误!\n这不是一个服务器地址。");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1416,13 +1414,18 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
TaskUtility.StartAndAwaitTask(() =>
|
TaskUtility.StartAndAwaitTask(() =>
|
||||||
{
|
{
|
||||||
if (OnBeforeConnectEvent(EventArgs) == EventResult.Fail) return;
|
if (OnBeforeConnectEvent(EventArgs) == EventResult.Fail) return;
|
||||||
result = RunTime.Controller?.Connect() ?? result;
|
result = RunTime.Controller?.Connect(RunTime.Session.Server_IP, RunTime.Session.Server_Port) ?? result;
|
||||||
EventArgs.ConnectResult = result;
|
EventArgs.ConnectResult = result;
|
||||||
}).OnCompleted(() =>
|
}).OnCompleted(() =>
|
||||||
{
|
{
|
||||||
if (result == ConnectResult.Success) OnSucceedConnectEvent(EventArgs);
|
if (result == ConnectResult.Success) OnSucceedConnectEvent(EventArgs);
|
||||||
else OnFailedConnectEvent(EventArgs);
|
else OnFailedConnectEvent(EventArgs);
|
||||||
OnAfterConnectEvent(EventArgs);
|
OnAfterConnectEvent(EventArgs);
|
||||||
|
}).OnError(e =>
|
||||||
|
{
|
||||||
|
GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
|
UpdateUI(MainInvokeType.SetRed);
|
||||||
|
Config.FunGame_isRetrying = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -1441,9 +1444,15 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
TaskUtility.StartAndAwaitTask(() =>
|
TaskUtility.StartAndAwaitTask(async () =>
|
||||||
{
|
{
|
||||||
if (OnBeforeDisconnectEvent(new GeneralEventArgs()) == EventResult.Fail) return;
|
if (OnBeforeDisconnectEvent(new GeneralEventArgs()) == EventResult.Fail) return;
|
||||||
|
|
||||||
|
if (Usercfg.LoginUser.Id != 0)
|
||||||
|
{
|
||||||
|
await LogOut();
|
||||||
|
}
|
||||||
|
|
||||||
result = RunTime.Controller?.Disconnect() ?? false;
|
result = RunTime.Controller?.Disconnect() ?? false;
|
||||||
}).OnCompleted(() =>
|
}).OnCompleted(() =>
|
||||||
{
|
{
|
||||||
@ -1486,6 +1495,34 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建房间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="room"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> InvokeController_CreateRoom(string RoomType, string Password = "")
|
||||||
|
{
|
||||||
|
string roomid = "-1";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RoomEventArgs EventArgs = new(RoomType, Password);
|
||||||
|
if (OnBeforeCreateRoomEvent(EventArgs) == EventResult.Fail) return roomid;
|
||||||
|
|
||||||
|
roomid = MainController is null ? "-1" : await MainController.CreateRoomAsync(RoomType, Password);
|
||||||
|
|
||||||
|
if (roomid != "-1") OnSucceedCreateRoomEvent(EventArgs);
|
||||||
|
else OnFailedCreateRoomEvent(EventArgs);
|
||||||
|
OnAfterCreateRoomEvent(EventArgs);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
GetMessage(e.GetErrorInfo(), TimeType.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
return roomid;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 退出房间
|
/// 退出房间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,7 +53,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:最多6个中文字符或12个英文字符");
|
ShowMessage(ShowMessageType.Error, "账号名长度不符合要求:3~12个字符数(一个中文2个字符)");
|
||||||
UsernameText.Focus();
|
UsernameText.Focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
if (password != "")
|
if (password != "")
|
||||||
{
|
{
|
||||||
int length = password.Length;
|
int length = password.Length;
|
||||||
if (length < 6 || length > 15) // 字节范围 3~12
|
if (length < 6 || length > 15) // 字节范围 6~15
|
||||||
{
|
{
|
||||||
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
ShowMessage(ShowMessageType.Error, "密码长度不符合要求:6~15个字符数");
|
||||||
PasswordText.Focus();
|
PasswordText.Focus();
|
||||||
@ -121,11 +121,14 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
return EventResult.Success;
|
return EventResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void RegButton_Click(object sender, EventArgs e)
|
private void RegButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RegButton.Enabled = false;
|
RegButton.Enabled = false;
|
||||||
|
TaskUtility.StartAndAwaitTask(async() =>
|
||||||
|
{
|
||||||
if (!await Reg_Handler()) RegButton.Enabled = true;
|
if (!await Reg_Handler()) RegButton.Enabled = true;
|
||||||
else Dispose();
|
else Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoToLogin_Click(object sender, EventArgs e)
|
private void GoToLogin_Click(object sender, EventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user