【服务器】服务器选择界面每次打开时都重新获取一遍服务器列表数据

dev_chengFeng
gaoxin 2021-08-09 16:32:14 +08:00
parent c4c57893ea
commit 8e43418825
1 changed files with 36 additions and 15 deletions

View File

@ -145,22 +145,43 @@ function this:BindEvent()
---SelectServer
Util.AddClick(this.changeServerBtn, function()
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]
local function reServerCallback(str)
if str == nil then
return
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)