From 7d24023a4c738f85b3d77d071dccc2f90bf93ac1 Mon Sep 17 00:00:00 2001 From: Yezi <53083103+yeziuku@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8=E5=8D=B1?= =?UTF-8?q?=E5=AE=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunGame.Desktop/Model/LoginModel.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/FunGame.Desktop/Model/LoginModel.cs b/FunGame.Desktop/Model/LoginModel.cs index 956339e..6309d98 100644 --- a/FunGame.Desktop/Model/LoginModel.cs +++ b/FunGame.Desktop/Model/LoginModel.cs @@ -18,7 +18,6 @@ namespace Milimoe.FunGame.Desktop.Model { private static SocketObject Work; private static bool Working = false; - private static bool Success = false; public LoginModel() : base(RunTime.Socket) { @@ -29,9 +28,11 @@ namespace Milimoe.FunGame.Desktop.Model { try { - Work = SocketObject; - Success = true; - Working = false; + if (SocketObject.SocketType == SocketMessageType.Login || SocketObject.SocketType == SocketMessageType.CheckLogin) + { + Work = SocketObject; + Working = false; + } } catch (Exception e) { @@ -53,9 +54,9 @@ namespace Milimoe.FunGame.Desktop.Model if (objs.Length > 1) password = (string)objs[1]; if (objs.Length > 2) autokey = (string)objs[2]; password = password.Encrypt(username); + SetWorking(); if (Socket.Send(SocketMessageType.Login, username, password, autokey) == SocketResult.Success) { - SetWorking(); string ErrorMsg = ""; Guid CheckLoginKey = Guid.Empty; (CheckLoginKey, ErrorMsg) = await Task.Factory.StartNew(GetCheckLoginKeyAsync); @@ -64,9 +65,9 @@ namespace Milimoe.FunGame.Desktop.Model ShowMessage.ErrorMessage(ErrorMsg, "登录失败"); return false; } + SetWorking(); if (Socket.Send(SocketMessageType.CheckLogin, CheckLoginKey) == SocketResult.Success) { - SetWorking(); DataSet ds = await Task.Factory.StartNew(GetLoginUserAsync); if (ds != null) { @@ -96,7 +97,7 @@ namespace Milimoe.FunGame.Desktop.Model { if (!Working) break; } - if (Success) + if (Work != null) { // 返回一个确认登录的Key if (Work.Length > 0) key = Work.GetParam(0); @@ -124,7 +125,7 @@ namespace Milimoe.FunGame.Desktop.Model { if (!Working) break; } - if (Success) + if (Work != null) { // 返回构造User对象的DataTable if (Work.Length > 0) ds = Work.GetParam(0); @@ -141,7 +142,6 @@ namespace Milimoe.FunGame.Desktop.Model private static void SetWorking() { Working = true; - Success = false; Work = default; } }