重连和登录时断开之前的socket连接
parent
aea9b03f5f
commit
3d3a51fbb0
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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, "重新登录")
|
||||
|
|
|
@ -37,8 +37,7 @@ function this.Initialize()
|
|||
--Util.LogError(debug.traceback("<color=#00ccee>onSwitchAccountCallback:" .. result[1] .. "</color>"))
|
||||
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("<color=#00ccee>onLogoutCallback:" .. result[1] .. "</color>"))
|
||||
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
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue