添加服务器强制将玩家下线

This commit is contained in:
Mili 2023-04-02 19:21:16 +08:00
parent 60b645d09d
commit 0011720dce

View File

@ -34,7 +34,7 @@ namespace Milimoe.FunGame.Desktop.Model
string msg = ""; string msg = "";
Guid key = Guid.Empty; Guid key = Guid.Empty;
(msg, key) = await Task.Factory.StartNew(SocketHandler_LogOut); (msg, key) = await Task.Factory.StartNew(SocketHandler_LogOut);
if (key != Guid.Empty) if (key == Config.Guid_LoginKey)
{ {
Config.Guid_LoginKey = Guid.Empty; Config.Guid_LoginKey = Guid.Empty;
Main.UpdateUI(MainInvokeType.LogOut, msg ?? ""); Main.UpdateUI(MainInvokeType.LogOut, msg ?? "");
@ -145,6 +145,7 @@ namespace Milimoe.FunGame.Desktop.Model
Main.GetMessage(msg, TimeType.None); Main.GetMessage(msg, TimeType.None);
return true; return true;
} }
else return false;
} }
throw new CanNotSendTalkException(); throw new CanNotSendTalkException();
} }
@ -168,6 +169,20 @@ namespace Milimoe.FunGame.Desktop.Model
if ((RunTime.Socket?.Connected ?? false) && Usercfg.LoginUser != null) if ((RunTime.Socket?.Connected ?? false) && Usercfg.LoginUser != null)
Main.UpdateUI(MainInvokeType.SetGreenAndPing); 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);
msg ??= "";
if (key == Config.Guid_LoginKey)
{
Config.Guid_LoginKey = Guid.Empty;
Main.UpdateUI(MainInvokeType.LogOut, msg ?? "");
}
}
else if (SocketMessageTypes.Contains(SocketObject.SocketType)) else if (SocketMessageTypes.Contains(SocketObject.SocketType))
{ {
Work = SocketObject; Work = SocketObject;