重连和登录时断开之前的socket连接
parent
aea9b03f5f
commit
3d3a51fbb0
|
@ -28,8 +28,7 @@ local update = function()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
MsgPanel.ShowTwo("是否退出游戏?", nil, function()
|
MsgPanel.ShowTwo("是否退出游戏?", nil, function()
|
||||||
Framework.Dispose()
|
Game.Quit()
|
||||||
UnityEngine.Application.Quit()
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -37,8 +36,7 @@ local update = function()
|
||||||
-- 临时退出游戏代码
|
-- 临时退出游戏代码
|
||||||
if not AppConst.isSDK and Input.GetKeyDown(UnityEngine.KeyCode.Tab) then
|
if not AppConst.isSDK and Input.GetKeyDown(UnityEngine.KeyCode.Tab) then
|
||||||
MsgPanel.ShowTwo("您确定要重新登录?", nil, function()
|
MsgPanel.ShowTwo("您确定要重新登录?", nil, function()
|
||||||
Framework.Dispose()
|
Game.Logout()
|
||||||
App.Instance:ReStart()
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ function Game.InitManagers()
|
||||||
this.managerList = {}
|
this.managerList = {}
|
||||||
for i, v in ipairs(managers) do
|
for i, v in ipairs(managers) do
|
||||||
this.managerList[i] = require("Modules/"..v)
|
this.managerList[i] = require("Modules/"..v)
|
||||||
|
|
||||||
if this.managerList[i].Initialize then
|
if this.managerList[i].Initialize then
|
||||||
this.managerList[i].Initialize()
|
this.managerList[i].Initialize()
|
||||||
end
|
end
|
||||||
|
@ -41,6 +42,28 @@ function Game.LateUpdate()
|
||||||
end
|
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)
|
function Game.OnApplicationPause(pauseStatus)
|
||||||
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
|
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
|
||||||
|
|
|
@ -50,8 +50,7 @@ end
|
||||||
--异常断线--
|
--异常断线--
|
||||||
function Network:OnException()
|
function Network:OnException()
|
||||||
MsgPanel.ShowOne("网络异常,请重新登录!", function()
|
MsgPanel.ShowOne("网络异常,请重新登录!", function()
|
||||||
Framework.Dispose()
|
Game.Logout()
|
||||||
App.Instance:ReStart()
|
|
||||||
end)
|
end)
|
||||||
self.bIsStartListenHeartBeat = false
|
self.bIsStartListenHeartBeat = false
|
||||||
Game.GlobalEvent:DispatchEvent(Protocal.Exception, self)
|
Game.GlobalEvent:DispatchEvent(Protocal.Exception, self)
|
||||||
|
@ -112,12 +111,7 @@ function Network:OnReconnectFail()
|
||||||
if self.re_resendTimes > self.re_maxResendTimes then
|
if self.re_resendTimes > self.re_maxResendTimes then
|
||||||
RequestPanel.Hide()
|
RequestPanel.Hide()
|
||||||
MsgPanel.ShowTwo("重连失败,是否尝试重连?", function()
|
MsgPanel.ShowTwo("重连失败,是否尝试重连?", function()
|
||||||
if AppConst.isSDKLogin then
|
Game.Logout()
|
||||||
SDKMgr:Logout()
|
|
||||||
else
|
|
||||||
Framework.Dispose()
|
|
||||||
App.Instance:ReStart()
|
|
||||||
end
|
|
||||||
end, function()
|
end, function()
|
||||||
RequestPanel.Show("正在请求重连")
|
RequestPanel.Show("正在请求重连")
|
||||||
self.re_sendWaitTime = 0
|
self.re_sendWaitTime = 0
|
||||||
|
@ -218,8 +212,7 @@ function Network:ReceiveErrorInfo(buffer)
|
||||||
else
|
else
|
||||||
if msg.errCode == -101 or msg.errCode == -102 then
|
if msg.errCode == -101 or msg.errCode == -102 then
|
||||||
--被顶号或者被封号
|
--被顶号或者被封号
|
||||||
Framework.Dispose()
|
Game.Logout()
|
||||||
App.Instance:ReStart()
|
|
||||||
AppConst.Code = msg.errMsg --TODO:重登会重置所有lua变量信息,用一个不用的C#变量记录,用于记录异常退出信息
|
AppConst.Code = msg.errMsg --TODO:重登会重置所有lua变量信息,用一个不用的C#变量记录,用于记录异常退出信息
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -265,12 +258,7 @@ function Network:Update()
|
||||||
elseif self.resendTimes == self.maxResendTimes then
|
elseif self.resendTimes == self.maxResendTimes then
|
||||||
RequestPanel.Hide()
|
RequestPanel.Hide()
|
||||||
MsgPanel.ShowTwo("请求失败,是否重新请求?", function()
|
MsgPanel.ShowTwo("请求失败,是否重新请求?", function()
|
||||||
if AppConst.isSDKLogin then
|
Game.Logout()
|
||||||
SDKMgr:Logout()
|
|
||||||
else
|
|
||||||
Framework.Dispose()
|
|
||||||
App.Instance:ReStart()
|
|
||||||
end
|
|
||||||
end, function()
|
end, function()
|
||||||
self.resendTimes = 0
|
self.resendTimes = 0
|
||||||
end, "重新登录")
|
end, "重新登录")
|
||||||
|
|
|
@ -37,8 +37,7 @@ function this.Initialize()
|
||||||
--Util.LogError(debug.traceback("<color=#00ccee>onSwitchAccountCallback:" .. result[1] .. "</color>"))
|
--Util.LogError(debug.traceback("<color=#00ccee>onSwitchAccountCallback:" .. result[1] .. "</color>"))
|
||||||
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
||||||
ThinkingAnalyticsManager.Track("change_account")
|
ThinkingAnalyticsManager.Track("change_account")
|
||||||
Framework.Dispose()
|
Game.Restart()
|
||||||
App.Instance:ReStart()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,8 +47,7 @@ function this.Initialize()
|
||||||
--Util.LogError(debug.traceback("<color=#00ccee>onLogoutCallback:" .. result[1] .. "</color>"))
|
--Util.LogError(debug.traceback("<color=#00ccee>onLogoutCallback:" .. result[1] .. "</color>"))
|
||||||
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
||||||
ThinkingAnalyticsManager.Track("quit_account")
|
ThinkingAnalyticsManager.Track("quit_account")
|
||||||
Framework.Dispose()
|
Game.Restart()
|
||||||
App.Instance:ReStart()
|
|
||||||
end
|
end
|
||||||
-- 发送登出事件
|
-- 发送登出事件
|
||||||
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLogout)
|
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLogout)
|
||||||
|
@ -128,20 +126,4 @@ function this.RequestUser(name, pw, call)
|
||||||
end,nil,nil,nil)
|
end,nil,nil,nil)
|
||||||
end
|
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
|
return this
|
|
@ -8,7 +8,7 @@ this.LoginWay = { Account = 0, WeChat = 1 }
|
||||||
local ServerVersion = 1
|
local ServerVersion = 1
|
||||||
|
|
||||||
local IsSDKLogin = AppConst.isSDK and AppConst.isSDKLogin
|
local IsSDKLogin = AppConst.isSDK and AppConst.isSDKLogin
|
||||||
local IsDevelopLogin = false
|
local IsDevelopLogin = true
|
||||||
|
|
||||||
local openIdkey = "openIdkey"
|
local openIdkey = "openIdkey"
|
||||||
local openIdPw = "openIdPw"
|
local openIdPw = "openIdPw"
|
||||||
|
@ -561,7 +561,9 @@ end
|
||||||
|
|
||||||
-- 请求连接socket
|
-- 请求连接socket
|
||||||
function this.RequestSocketLogin()
|
function this.RequestSocketLogin()
|
||||||
|
LogRed("请求连接Socket")
|
||||||
RequestPanel.Show(Language[11124])
|
RequestPanel.Show(Language[11124])
|
||||||
|
SocketManager.Disconnect(SocketType.LOGIN)
|
||||||
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
|
SocketManager.AddNetwork(SocketType.LOGIN, LoginManager.SocketAddress, LoginManager.SocketPort)
|
||||||
SocketManager.TryConnect(SocketType.LOGIN)
|
SocketManager.TryConnect(SocketType.LOGIN)
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,12 +69,7 @@ function SettingInfo:BindEvent()
|
||||||
|
|
||||||
Util.AddClick(this.btnChangeLogin, function()
|
Util.AddClick(this.btnChangeLogin, function()
|
||||||
MsgPanel.ShowTwo(Language[11895], nil, function()
|
MsgPanel.ShowTwo(Language[11895], nil, function()
|
||||||
if AppConst.isSDKLogin then
|
Game.Logout()
|
||||||
SDKMgr:Logout()
|
|
||||||
else
|
|
||||||
Framework.Dispose()
|
|
||||||
App.Instance:ReStart()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue