diff --git a/Assets/ManagedResources/~Lua/Framework/Framework.lua b/Assets/ManagedResources/~Lua/Framework/Framework.lua
index 967374ddd0..64ff342094 100644
--- a/Assets/ManagedResources/~Lua/Framework/Framework.lua
+++ b/Assets/ManagedResources/~Lua/Framework/Framework.lua
@@ -28,8 +28,7 @@ local update = function()
end
else
MsgPanel.ShowTwo("是否退出游戏?", nil, function()
- Framework.Dispose()
- UnityEngine.Application.Quit()
+ Game.Quit()
end)
end
end
@@ -37,8 +36,7 @@ local update = function()
-- 临时退出游戏代码
if not AppConst.isSDK and Input.GetKeyDown(UnityEngine.KeyCode.Tab) then
MsgPanel.ShowTwo("您确定要重新登录?", nil, function()
- Framework.Dispose()
- App.Instance:ReStart()
+ Game.Logout()
end)
end
diff --git a/Assets/ManagedResources/~Lua/Logic/Game.lua b/Assets/ManagedResources/~Lua/Logic/Game.lua
index 7553501aa0..10348a1309 100644
--- a/Assets/ManagedResources/~Lua/Logic/Game.lua
+++ b/Assets/ManagedResources/~Lua/Logic/Game.lua
@@ -23,6 +23,7 @@ function Game.InitManagers()
this.managerList = {}
for i, v in ipairs(managers) do
this.managerList[i] = require("Modules/"..v)
+
if this.managerList[i].Initialize then
this.managerList[i].Initialize()
end
@@ -41,6 +42,28 @@ function Game.LateUpdate()
end
+function Game.Logout()
+ if AppConst.isSDKLogin then
+ SDKMgr:Logout()
+ else
+ Game.Restart()
+ end
+end
+
+function Game.Restart()
+ Framework.Dispose()
+ -- 退出时把socket断掉
+ SocketManager.Disconnect(SocketType.LOGIN)
+ --
+ App.Instance:ReStart()
+end
+
+function Game.Quit()
+
+ Framework.Dispose()
+ UnityEngine.Application.Quit()
+end
+
--应用程序暂停/恢复
function Game.OnApplicationPause(pauseStatus)
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
diff --git a/Assets/ManagedResources/~Lua/Logic/Network.lua b/Assets/ManagedResources/~Lua/Logic/Network.lua
index 10b84227e7..03386a2403 100644
--- a/Assets/ManagedResources/~Lua/Logic/Network.lua
+++ b/Assets/ManagedResources/~Lua/Logic/Network.lua
@@ -50,8 +50,7 @@ end
--异常断线--
function Network:OnException()
MsgPanel.ShowOne("网络异常,请重新登录!", function()
- Framework.Dispose()
- App.Instance:ReStart()
+ Game.Logout()
end)
self.bIsStartListenHeartBeat = false
Game.GlobalEvent:DispatchEvent(Protocal.Exception, self)
@@ -112,12 +111,7 @@ function Network:OnReconnectFail()
if self.re_resendTimes > self.re_maxResendTimes then
RequestPanel.Hide()
MsgPanel.ShowTwo("重连失败,是否尝试重连?", function()
- if AppConst.isSDKLogin then
- SDKMgr:Logout()
- else
- Framework.Dispose()
- App.Instance:ReStart()
- end
+ Game.Logout()
end, function()
RequestPanel.Show("正在请求重连")
self.re_sendWaitTime = 0
@@ -218,8 +212,7 @@ function Network:ReceiveErrorInfo(buffer)
else
if msg.errCode == -101 or msg.errCode == -102 then
--被顶号或者被封号
- Framework.Dispose()
- App.Instance:ReStart()
+ Game.Logout()
AppConst.Code = msg.errMsg --TODO:重登会重置所有lua变量信息,用一个不用的C#变量记录,用于记录异常退出信息
end
end
@@ -265,12 +258,7 @@ function Network:Update()
elseif self.resendTimes == self.maxResendTimes then
RequestPanel.Hide()
MsgPanel.ShowTwo("请求失败,是否重新请求?", function()
- if AppConst.isSDKLogin then
- SDKMgr:Logout()
- else
- Framework.Dispose()
- App.Instance:ReStart()
- end
+ Game.Logout()
end, function()
self.resendTimes = 0
end, "重新登录")
diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua
index a40458e0b6..9f427618f7 100644
--- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua
+++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua
@@ -37,8 +37,7 @@ function this.Initialize()
--Util.LogError(debug.traceback("onSwitchAccountCallback:" .. result[1] .. ""))
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
ThinkingAnalyticsManager.Track("change_account")
- Framework.Dispose()
- App.Instance:ReStart()
+ Game.Restart()
end
end
@@ -48,8 +47,7 @@ function this.Initialize()
--Util.LogError(debug.traceback("onLogoutCallback:" .. result[1] .. ""))
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
ThinkingAnalyticsManager.Track("quit_account")
- Framework.Dispose()
- App.Instance:ReStart()
+ Game.Restart()
end
-- 发送登出事件
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLogout)
@@ -128,20 +126,4 @@ function this.RequestUser(name, pw, call)
end,nil,nil,nil)
end
---注销
-function this.LogOut()
- this.CurLoginWay=-1
- this.CurAccount=''
- this.CurSession=''
- --sdkMgr:ClearSession()
- --[[
- PlayerPrefs.DeleteKey(this.GameName.."LoginWay")
- PlayerPrefs.DeleteKey(this.GameName.."Account")
- PlayerPrefs.DeleteKey(this.GameName.."Session")
- ]]--
- Framework.Dispose();
- --sdkMgr:LogOutTime(tostring(PlayerManager.player.id));
- App.Instance:ReStart();
-end
-
return this
\ No newline at end of file
diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua
index 82e2f3d790..a94f3d653f 100644
--- a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua
+++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua
@@ -8,7 +8,7 @@ this.LoginWay = { Account = 0, WeChat = 1 }
local ServerVersion = 1
local IsSDKLogin = AppConst.isSDK and AppConst.isSDKLogin
-local IsDevelopLogin = false
+local IsDevelopLogin = true
local openIdkey = "openIdkey"
local openIdPw = "openIdPw"
@@ -561,7 +561,9 @@ end
-- 请求连接socket
function this.RequestSocketLogin()
+ LogRed("请求连接Socket")
RequestPanel.Show(Language[11124])
+ SocketManager.Disconnect(SocketType.LOGIN)
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
SocketManager.TryConnect(SocketType.LOGIN)
end
diff --git a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua
index 02d7acdbb4..de527fd5cd 100644
--- a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua
+++ b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua
@@ -69,12 +69,7 @@ function SettingInfo:BindEvent()
Util.AddClick(this.btnChangeLogin, function()
MsgPanel.ShowTwo(Language[11895], nil, function()
- if AppConst.isSDKLogin then
- SDKMgr:Logout()
- else
- Framework.Dispose()
- App.Instance:ReStart()
- end
+ Game.Logout()
end)
end)