【服务器】服务器选择界面每次打开时都重新获取一遍服务器列表数据
parent
c4c57893ea
commit
8e43418825
|
@ -145,22 +145,43 @@ function this:BindEvent()
|
||||||
|
|
||||||
---SelectServer
|
---SelectServer
|
||||||
Util.AddClick(this.changeServerBtn, function()
|
Util.AddClick(this.changeServerBtn, function()
|
||||||
UIManager.OpenPanel(UIName.ServerListSelectPanel, {
|
local function reServerCallback(str)
|
||||||
serverList = this.serverList,
|
if str == nil then
|
||||||
myServerList = this.myServerList,
|
return
|
||||||
lastServer = this.lastServer,
|
|
||||||
recommend = this.recommend,
|
|
||||||
callback = function(index)
|
|
||||||
local list = this.serverList[index]
|
|
||||||
PlayerManager.serverInfo = list
|
|
||||||
LoginManager.SocketAddress = list.ip
|
|
||||||
LoginManager.SocketPort = list.port
|
|
||||||
LoginManager.ServerId = list.server_id
|
|
||||||
LoginManager.state = list.state
|
|
||||||
--local severArea = tonumber(string.sub(list.server_id, 0, -5))
|
|
||||||
this.serverMes.text = PlayerManager.serverInfo.name-- .. "\t<color=#56F384FF>" .. severArea .. "</color>" .. Language[11138]
|
|
||||||
end
|
end
|
||||||
})
|
if str ~= nil and str ~= "" then
|
||||||
|
MyPCall(function()
|
||||||
|
local json = require 'cjson'
|
||||||
|
local data = json.decode(str)
|
||||||
|
-- selectServerPart
|
||||||
|
this.SetServerList(data)
|
||||||
|
-- 打开服务器选择界面
|
||||||
|
UIManager.OpenPanel(UIName.ServerListSelectPanel, {
|
||||||
|
serverList = this.serverList,
|
||||||
|
myServerList = this.myServerList,
|
||||||
|
lastServer = this.lastServer,
|
||||||
|
recommend = this.recommend,
|
||||||
|
callback = function(index)
|
||||||
|
local list = this.serverList[index]
|
||||||
|
PlayerManager.serverInfo = list
|
||||||
|
LoginManager.SocketAddress = list.ip
|
||||||
|
LoginManager.SocketPort = list.port
|
||||||
|
LoginManager.ServerId = list.server_id
|
||||||
|
LoginManager.state = list.state
|
||||||
|
--local severArea = tonumber(string.sub(list.server_id, 0, -5))
|
||||||
|
this.serverMes.text = PlayerManager.serverInfo.name-- .. "\t<color=#56F384FF>" .. severArea .. "</color>" .. Language[11138]
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- 判断获取服务器的id
|
||||||
|
if IsSDKLogin then
|
||||||
|
this.RequestServerList(AppConst.OpenId, reServerCallback)
|
||||||
|
else
|
||||||
|
local userId = PlayerPrefs.GetString(openIdkey, defaultOpenIdkey)
|
||||||
|
this.RequestServerList(userId, reServerCallback)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue