LoginProxy.lua 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local LoginProxy = class("LoginProxy", RemoteProxy)
  3. LoginProxy.NAME = global.ProxyTable.Login
  4. local cjson = require("cjson")
  5. local connectTimeOut = 5
  6. -- 网络消息水印头
  7. function GET_NET_MSG_STAMP_HEAD_RECOG()
  8. return 900000
  9. end
  10. function GET_NET_MSG_STAMP_HEAD_PARAM1()
  11. return math.random(1,1000000000)
  12. end
  13. LoginProxy.param1Ex = nil
  14. function GET_NET_MSG_STAMP_HEAD_PARAM1_NEW(func)
  15. if LoginProxy.param1Ex then
  16. func(LoginProxy.param1Ex)
  17. return
  18. end
  19. local currentModule = global.L_ModuleManager:GetCurrentModule()
  20. local moduleGameEnv = currentModule:GetGameEnv()
  21. local NetStampHost = moduleGameEnv:GetCustomDataByKey("NetStampHost")
  22. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  23. local serverID = tonumber(LoginProxy:GetMainSelectedServerId() or LoginProxy:GetSelectedServerId()) or 0
  24. local netUrl = string.format("%s%s.txt", NetStampHost, get_str_MD5(tostring(serverID)))
  25. local fileUtil = cc.FileUtils:getInstance()
  26. local filePath = fileUtil:getWritablePath() .. "_temp_net_"
  27. if fileUtil:isFileExist(filePath) then
  28. fileUtil:removeFile(filePath)
  29. end
  30. HTTPRequest(netUrl,function (success, response)
  31. local param1 = bit._and(math.random(100000000,2100000000),0xFFFF00FF)
  32. if success then
  33. fileUtil:writeStringToFile(response, filePath)
  34. local netInfoStr = fileUtil:getDataFromFileEx(filePath)
  35. local netInfo = cjson.decode(netInfoStr)
  36. local index = L8Bit(netInfo.UnixTime) + 1
  37. param1 = netInfo.Sequence[index]
  38. param1 = tonumber(param1) or 0
  39. LoginProxy.param1Ex = param1
  40. end
  41. func(param1)
  42. end)
  43. end
  44. function LoginProxy:ctor()
  45. LoginProxy.super.ctor(self)
  46. self._data = {}
  47. -- 角色
  48. self._data.roles = {}
  49. self._data.selectRole = {}
  50. self._data.restoreRoleDatas ={}
  51. self._restoreTag = nil
  52. -- util
  53. self._netMsgSpecialData = nil
  54. self._tipsContent = ""
  55. self._serviceVer = ""
  56. self._forbidName = false -- 服务器控制开关,是否禁止取名字
  57. self._forbidChat = false -- 服务器控制开关,是否禁止聊天等
  58. self._loginKey = "" -- 529号消息返回的key
  59. self._newLogin = false -- 新的登录方式
  60. self.reqCreateRoleScheduleID = nil -- 请求创建定时器
  61. self._isNewLimit = false -- 是否收到图片验证码消息
  62. end
  63. function LoginProxy:IsForbidName()
  64. return self._forbidName
  65. end
  66. function LoginProxy:SetForbidChat(v)
  67. self._forbidChat = v
  68. end
  69. function LoginProxy:IsForbidChat()
  70. return self._forbidChat
  71. end
  72. function LoginProxy:SetTipsContent(content)
  73. self._tipsContent = content
  74. end
  75. function LoginProxy:GetTipsContent()
  76. return self._tipsContent
  77. end
  78. function LoginProxy:SetServiceVer(ver)
  79. self._serviceVer = ver
  80. end
  81. function LoginProxy:GetServiceVer()
  82. return self._serviceVer
  83. end
  84. function LoginProxy:GetSelectedServer()
  85. local currentModule = global.L_ModuleManager:GetCurrentModule()
  86. local moduleGameEnv = currentModule:GetGameEnv()
  87. return moduleGameEnv:GetSelectedServer()
  88. end
  89. function LoginProxy:GetSelectedServerDomain() -- 当前选择的服务器 域名
  90. local server = self:GetSelectedServer()
  91. if server then
  92. return server.ip
  93. end
  94. return nil
  95. end
  96. function LoginProxy:GetMainSelectedServerId() -- 当前选择的服务器 主服id
  97. local server = self:GetSelectedServer()
  98. if server then
  99. return server.mainServerId
  100. end
  101. return nil
  102. end
  103. function LoginProxy:GetSelectedServerId() -- 当前选择的服务器 id
  104. local server = self:GetSelectedServer()
  105. if server then
  106. return server.serverId
  107. end
  108. return nil
  109. end
  110. function LoginProxy:GetSelectedServerName() -- 当前选择的服务器 name
  111. local server = self:GetSelectedServer()
  112. if server then
  113. return server.serverName
  114. end
  115. return nil
  116. end
  117. function LoginProxy:GetSelectedServerUrlSuffix() -- 当前选择的服务器 资源URL 后缀
  118. local server = self:GetSelectedServer()
  119. if server then
  120. return server.urlSuffix
  121. end
  122. return nil
  123. end
  124. function LoginProxy:GetSelectedServerIp() -- 当前选择的服务器 ip 地址
  125. local server = self:GetSelectedServer()
  126. if server then
  127. return server.ip
  128. end
  129. return nil
  130. end
  131. function LoginProxy:GetSelectedServerPort() -- 当前选择的服务器 端口
  132. local server = self:GetSelectedServer()
  133. if server then
  134. return tonumber(server.port)
  135. end
  136. return nil
  137. end
  138. function LoginProxy:GetSelectedServerProxyPort() -- 当前选择的服务器 代理端口
  139. local server = self:GetSelectedServer()
  140. if server then
  141. return tonumber(server.proxyport)
  142. end
  143. return nil
  144. end
  145. function LoginProxy:SetGameServerPort(port)
  146. self._data.gameServerPort = port
  147. end
  148. function LoginProxy:GetGameServerPort()
  149. return self._data.gameServerPort
  150. end
  151. function LoginProxy:SetRolePort(port)
  152. self._data.rolePort = port
  153. end
  154. function LoginProxy:GetRolePort()
  155. return self._data.rolePort
  156. end
  157. -- roles
  158. function LoginProxy:SetSelectedRole(role)
  159. self._data.selectRole = role
  160. end
  161. function LoginProxy:GetSelectedRole()
  162. return self._data.selectRole
  163. end
  164. function LoginProxy:SetSelectedRoleByIndex(index)
  165. local role = self._data.roles[index]
  166. if role then
  167. self._data.selectRole = role
  168. end
  169. end
  170. function LoginProxy:GetSelectedRoleName() -- 当前选择的角色 name
  171. if self._data.selectRole then
  172. return self._data.selectRole.name
  173. end
  174. return nil
  175. end
  176. function LoginProxy:GetSelectedRoleID() --当前选择的角色ID
  177. if self._data.selectRole then
  178. return self._data.selectRole.roleid
  179. end
  180. return nil
  181. end
  182. function LoginProxy:GetSelectedRoleCTime() --当前选择的角色创建时间
  183. if self._data.selectRole and self._data.selectRole.ctime then
  184. return self._data.selectRole.ctime
  185. end
  186. return 0
  187. end
  188. function LoginProxy:GetRoles()
  189. return self._data.roles
  190. end
  191. function LoginProxy:AddRole(role)
  192. table.insert(self._data.roles, role)
  193. for i, v in ipairs(self._data.roles) do
  194. v.index = i
  195. end
  196. end
  197. function LoginProxy:DelRoleByID(roleid)
  198. for k, v in pairs(self._data.roles) do
  199. if v.roleid == roleid then
  200. table.remove(self._data.roles, k)
  201. break
  202. end
  203. end
  204. for i, v in ipairs(self._data.roles) do
  205. v.index = i
  206. end
  207. end
  208. function LoginProxy:ClearRoles()
  209. self._data.roles = {}
  210. self._data.selectRole = nil
  211. end
  212. ---
  213. -- 服务器Special data
  214. function LoginProxy:SetNetMsgSpecialData(value)
  215. self._netMsgSpecialData = value
  216. end
  217. function LoginProxy:GetNetMsgSpecialData()
  218. return self._netMsgSpecialData
  219. end
  220. --
  221. -- step 0.
  222. function LoginProxy:RequestLoginServer()
  223. HideLoadingBar()
  224. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  225. local uid = AuthProxy:GetUID()
  226. local token = AuthProxy:GetToken()
  227. -- for debug mode, login whitelist
  228. if global.isDebugMode then
  229. token = "sJAsOn001"
  230. end
  231. self:RequestServerList(uid, token, function (ret)
  232. if 1 ~= ret then
  233. local function callback(bType, custom)
  234. if bType == 1 then
  235. if global.isWindows then
  236. global.Director:endToLua()
  237. else
  238. global.L_NativeBridgeManager:GN_accountLogout()
  239. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  240. end
  241. end
  242. end
  243. local data = {}
  244. data.str = GET_STRING(600003002)
  245. data.btnDesc = { GET_STRING(600003001)}
  246. data.callback = callback
  247. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  248. end
  249. end)
  250. -- 验证下渠道号地址
  251. AuthProxy:RequestModeInfoCheck()
  252. end
  253. -- step 1. 2001->
  254. function LoginProxy:RequestServerList(account, password, connectResfunc)
  255. releasePrint("step 1. function LoginProxy:RequestServerList(account, password)")
  256. local ret = -1
  257. local netClient = global.gameEnvironment:GetNetClient()
  258. local selectServer = self:GetSelectedServer()
  259. releasePrint(cjson.encode(selectServer))
  260. -- 没有选择服务器
  261. if not selectServer or not selectServer.ip or not selectServer.port then
  262. local function callback(bType, custom)
  263. if global.isWindows then
  264. global.Director:endToLua()
  265. else
  266. global.L_NativeBridgeManager:GN_accountLogout()
  267. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  268. end
  269. end
  270. local data = {}
  271. data.str = GET_STRING(30009001)
  272. data.btnDesc = {GET_STRING(1002)}
  273. data.callback = callback
  274. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  275. return ret
  276. end
  277. -- 服务器未开启
  278. local currentModule = global.L_ModuleManager:GetCurrentModule()
  279. local moduleGameEnv = currentModule:GetGameEnv()
  280. if selectServer.state == 4 and (moduleGameEnv:IsWhitelist() == false) then
  281. local function callback(bType, custom)
  282. if global.isWindows then
  283. global.Director:endToLua()
  284. else
  285. global.L_NativeBridgeManager:GN_accountLogout()
  286. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  287. end
  288. end
  289. local data = {}
  290. data.str = GET_STRING(30009002)
  291. data.btnDesc = {GET_STRING(1002)}
  292. data.callback = callback
  293. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  294. return ret
  295. end
  296. local ip = self:GetSelectedServerIp()
  297. local port = self:GetSelectedServerPort()
  298. local proxyport = self:GetSelectedServerProxyPort()
  299. local connectIP = tostring(ip)
  300. local connectPort = tonumber(proxyport or port)
  301. self:SetRolePort(connectPort)
  302. -- // connect server
  303. netClient:Disconnect()
  304. local Connect = function (param1Ex)
  305. ret = netClient:Connect(connectIP, connectPort)
  306. releasePrint("2001, connect:", connectIP, connectPort, ret)
  307. if 1 == ret then
  308. -- // 1. message 2001 - request server lis
  309. -- login
  310. self:send_MSG_CS_REQUEST_SERVER_LIST(account, password, param1Ex)
  311. end
  312. connectResfunc(ret)
  313. end
  314. if proxyport then
  315. GET_NET_MSG_STAMP_HEAD_PARAM1_NEW(function (param1Ex)
  316. Connect(param1Ex)
  317. end)
  318. else
  319. Connect()
  320. end
  321. end
  322. -- 2001 发送2001号消息
  323. function LoginProxy:send_MSG_CS_REQUEST_SERVER_LIST(account, password, param1Ex)
  324. -- body
  325. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  326. local LoginOtpPassWordProxy = global.Facade:retrieveProxy(global.ProxyTable.LoginOtpPassWordProxy)
  327. local pwdSession = Encode6BitBuf(password, string.len(password))
  328. local channelID = envProxy:GetChannelID()
  329. local encodechannelID = Encode6BitBuf(channelID, string.len(channelID))
  330. local otpType = LoginOtpPassWordProxy:getCheckType()
  331. local otpCode = LoginOtpPassWordProxy:getOtpCode()
  332. local sendStr = string.format("%s/%s/%s/%s/%s", account, pwdSession, encodechannelID, otpType, otpCode)
  333. local sendLen = string.len(sendStr)
  334. print("sendStr", sendStr, sendLen)
  335. local netClient = global.gameEnvironment:GetNetClient()
  336. netClient:SetNetMessageTypeSData(0)
  337. local recog = GET_NET_MSG_STAMP_HEAD_RECOG()
  338. local param1 = param1Ex or GET_NET_MSG_STAMP_HEAD_PARAM1()
  339. local param2 = tonumber(self:GetMainSelectedServerId() or self:GetSelectedServerId()) or 0
  340. local param3 = tonumber(self:GetSelectedServerPort()) or 0
  341. LuaSendMsg(global.MsgType.MSG_CS_REQUEST_SERVER_LIST, recog, param1, param2, param3, sendStr, sendLen)
  342. releasePrint("step 1. global.MsgType.MSG_CS_REQUEST_SERVER_LIST 2001", account, password, sendStr)
  343. self.reqServerListScheduleID = PerformWithDelayGlobal(function()
  344. self:connectTimeOutTips()
  345. self.reqServerListScheduleID = nil
  346. end, connectTimeOut)
  347. end
  348. function LoginProxy:handle_MSG_SC_RESPOINSE_CHECK_TOKEN_FAIL(msg)
  349. releasePrint("step 1. local function handle_MSG_SC_RESPOINSE_CHECK_TOKEN_FAIL(msg)")
  350. self:unScheduleServerList()
  351. -- recog -99 = 信息不全 -6 = 认证失败! 101 = 二次验证失败 999 = 账号被封
  352. local header = msg:GetHeader()
  353. if header.recog == -99 then
  354. local function callback(bType, custom)
  355. if global.isWindows then
  356. global.Director:endToLua()
  357. else
  358. global.L_NativeBridgeManager:GN_accountLogout()
  359. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  360. end
  361. end
  362. local data = {}
  363. data.str = GET_STRING(30009104)
  364. data.btnDesc = { GET_STRING(800802)}
  365. data.callback = callback
  366. data.hideCloseBtn = true
  367. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  368. elseif header.recog == -6 then
  369. local function callback(bType, custom)
  370. if global.isWindows then
  371. global.Director:endToLua()
  372. else
  373. global.L_NativeBridgeManager:GN_accountLogout()
  374. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  375. end
  376. end
  377. local data = {}
  378. data.str = GET_STRING(30009105)
  379. data.btnDesc = { GET_STRING(800802)}
  380. data.callback = callback
  381. data.hideCloseBtn = true
  382. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  383. elseif header.recog == 101 then
  384. local function callback(bType, custom)
  385. global.L_NativeBridgeManager:GN_accountLogout()
  386. global.Facade:sendNotification(global.NoticeTable.RestartGame)
  387. end
  388. local data = {}
  389. data.str = GET_STRING(30009108)
  390. data.btnDesc = { GET_STRING(800802)}
  391. data.callback = callback
  392. data.hideCloseBtn = true
  393. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  394. elseif header.recog == 999 then
  395. local time = header.param3
  396. local function callback(bType, custom)
  397. if global.isWindows then
  398. global.Director:endToLua()
  399. else
  400. global.L_NativeBridgeManager:GN_accountLogout()
  401. global.Facade:sendNotification(global.NoticeTable.RestartGame)
  402. end
  403. end
  404. local date = os.date("*t", time)
  405. local timeStr = string.format("%d-%02d-%02d %02d:%02d:%02d", date.year, date.month, date.day, date.hour, date.min, date.sec)
  406. local data = {}
  407. data.str = string.format("账号或IP已被限制登录,请稍后再试!\n\n解封时间:%s", timeStr)
  408. data.btnDesc = {GET_STRING(800802)}
  409. data.callback = callback
  410. data.hideCloseBtn = true
  411. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  412. end
  413. end
  414. function LoginProxy:recordLoginUserData2Bugly()
  415. -- record login user data
  416. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  417. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  418. local account = AuthProxy:GetUID()
  419. local serverID = self:GetSelectedServerId()
  420. local channelID = envProxy:GetChannelID()
  421. local etc2_enable = global.LuaBridgeCtl:GetModulesSwitch( global.MMO.Modules_Index_Enable_ETC2)
  422. local userValue = string.format("%s|%s|%s|%s", tostring(account), tostring(serverID), tostring(channelID), tostring(etc2_enable))
  423. -- account|serverID|channel
  424. if cc.PLATFORM_OS_ANDROID == global.Platform then
  425. buglyAddUserValue("LoginUserAccountData", userValue)
  426. else
  427. releasePrint("LoginUserAccountData:" .. userValue)
  428. end
  429. end
  430. -- step 2. ->529
  431. function LoginProxy:handle_MSG_SC_RESPONSE_SERVER_LIST(msg)
  432. releasePrint("step 2. local function handle_MSG_SC_RESPONSE_SERVER_LIST(msg)")
  433. local msgHdr = msg:GetHeader()
  434. self:unScheduleServerList()
  435. local data = msg:GetData()
  436. local dataStr = data:ReadString(msg:GetDataLength())
  437. local slices = string.split(dataStr, "/")
  438. local userID = slices[2]
  439. self._userID = userID
  440. self._loginKey = slices[1] or ""
  441. self._newLogin = msgHdr.recog == 1
  442. releasePrint("userID", userID)
  443. releasePrint("======529: ", string.format("数据: %s key: %s recog: %s", dataStr, self._loginKey, msgHdr.recog) )
  444. -- Data recording
  445. if cc.PLATFORM_OS_WINDOWS ~= global.Platform then
  446. local jData = {}
  447. jData.userID = userID
  448. jData.srvID = self:GetSelectedServerId()
  449. global.L_NativeBridgeManager:GN_onUserIDUpdated(jData)
  450. end
  451. -- record to bugly
  452. self:recordLoginUserData2Bugly()
  453. self:RequestServerInfo()
  454. end
  455. -- step 3. 104->
  456. function LoginProxy:RequestServerInfo()
  457. print("step 3. function LoginProxy:RequestServerInfo()")
  458. local serverId = self:GetSelectedServerId()
  459. local mainServerId = self:GetMainSelectedServerId()
  460. if not serverId or "" == serverId then
  461. local function callback(bType, custom)
  462. if bType == 1 then
  463. self:RequestLoginServer()
  464. elseif bType == 2 then
  465. if global.isWindows then
  466. global.Director:endToLua()
  467. else
  468. global.L_NativeBridgeManager:GN_accountLogout()
  469. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  470. end
  471. end
  472. end
  473. local data = {}
  474. data.str = GET_STRING(30009003)
  475. data.btnDesc = {"重 试", "返 回"}
  476. data.callback = callback
  477. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  478. -- print("error, RequestServerInfo, serverId:" .. tostring(serverId))
  479. return
  480. end
  481. local sendServerId = mainServerId or serverId
  482. if self._newLogin then
  483. sendServerId = Encode6BitBuf(self._loginKey, string.len(self._loginKey))
  484. end
  485. releasePrint("serverId", serverId)
  486. releasePrint("mainServerId", mainServerId)
  487. releasePrint("sendServerId", sendServerId)
  488. LuaSendMsg(global.MsgType.MSG_CS_REQUEST_SERVER_INFO, 0, 0, 0, 0, sendServerId, string.len(sendServerId))
  489. end
  490. -- step 4. ->530
  491. function LoginProxy:handle_MSG_SC_RESPONSE_SERVER_INFO(msg)
  492. print("step 4. local function handle_MSG_SC_RESPONSE_SERVER_INFO(msg)")
  493. if self._newLogin then
  494. ShowLoadingBar()
  495. local header = msg:GetHeader()
  496. local specialData = header.recog
  497. local netClient = global.gameEnvironment:GetNetClient()
  498. print("SetNetMessageTypeSData:", specialData)
  499. netClient:SetNetMessageTypeSData(specialData)
  500. self:SetNetMsgSpecialData(specialData)
  501. releasePrint("530: ", string.format("SessionId: %s", specialData) )
  502. self:RequestRoleInfo(specialData)
  503. return false
  504. end
  505. local data = msg:GetData()
  506. local dataStr = data:ReadString(msg:GetDataLength())
  507. local slices = string.split(dataStr, "/")
  508. local ip = tostring(slices[1])
  509. local port = tonumber(slices[2])
  510. local specialData = tonumber(slices[3])
  511. self:SetRolePort(port)
  512. ShowLoadingBar()
  513. -- // Disconnect current server and connect new server
  514. local netClient = global.gameEnvironment:GetNetClient()
  515. netClient:Disconnect()
  516. netClient:SetNetMessageTypeSData(specialData)
  517. self:SetNetMsgSpecialData(specialData)
  518. print("SetNetMessageTypeSData:", specialData)
  519. local ip = self:GetSelectedServerIp()
  520. local proxyport = self:GetSelectedServerProxyPort()
  521. local connectIP = tostring(ip)
  522. local connectPort = tonumber(proxyport or port)
  523. local errorTips = (connectPort == nil and 0) or (connectPort == 0 and 1) or nil
  524. if errorTips then
  525. ShowSystemTips(string.format(GET_STRING(30009300), errorTips))
  526. end
  527. local Connect = function (param1Ex)
  528. local ret = netClient:Connect(connectIP, connectPort)
  529. releasePrint("530, connect", connectIP, connectPort, ret)
  530. if 1 ~= ret then
  531. local function callback(bType, custom)
  532. if bType == 1 then
  533. self:RequestLoginServer()
  534. elseif bType == 2 then
  535. if global.isWindows then
  536. global.Director:endToLua()
  537. else
  538. global.L_NativeBridgeManager:GN_accountLogout()
  539. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  540. end
  541. end
  542. end
  543. local data = {}
  544. data.str = GET_STRING(30009003)
  545. data.btnDesc = {"重 试", "返 回"}
  546. data.callback = callback
  547. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  548. -- print("error, handle_MSG_SC_RESPONSE_SERVER_INFO:" .. tostring(ip) .. ":" .. tostring(port))
  549. return
  550. end
  551. -- // request role data of current account
  552. self:RequestRoleInfo(specialData, param1Ex)
  553. end
  554. if proxyport then
  555. GET_NET_MSG_STAMP_HEAD_PARAM1_NEW(function (param1Ex)
  556. Connect(param1Ex)
  557. end)
  558. else
  559. Connect()
  560. end
  561. end
  562. -- step 5. 100->
  563. function LoginProxy:RequestRoleInfo(specialData, param1Ex)
  564. print("step 5. function LoginProxy:RequestRoleInfo(specialData)")
  565. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  566. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  567. local account = AuthProxy:GetUID()
  568. local currModule= global.L_ModuleManager:GetCurrentModule()
  569. local gameid = currModule:GetOperID() or "0"
  570. -- login
  571. -- 100 (查询角色) 格式:帐号/SessionId/服务器名/主SdkId/子SdkId
  572. -- TODO, sdk id
  573. local sendStr = string.format("%s/%d/%s/%s/%s",
  574. account,
  575. specialData,
  576. self:GetSelectedServerId(),
  577. envProxy:GetChannelID(),
  578. gameid
  579. )
  580. local param3 = tonumber(self:GetRolePort()) or 0
  581. if self._newLogin then
  582. sendStr = string.format("%s/%s", sendStr, self._loginKey)
  583. param3 = tonumber(self:GetSelectedServerPort()) or 0
  584. end
  585. print("request role info")
  586. local recog = GET_NET_MSG_STAMP_HEAD_RECOG()
  587. local param1 = param1Ex or GET_NET_MSG_STAMP_HEAD_PARAM1()
  588. local param2 = tonumber(self:GetMainSelectedServerId() or self:GetSelectedServerId()) or 0
  589. LuaSendMsg(global.MsgType.MSG_CS_REQUEST_ROLE_INFO, recog, param1, param2, param3, sendStr, string.len(sendStr))
  590. end
  591. function LoginProxy:handle_MSG_SC_RESPOINSE_ROLE_INFO_FAIL(msg)
  592. print("step 6. local function handle_MSG_SC_RESPOINSE_ROLE_INFO_FAIL(msg)")
  593. HideLoadingBar(true)
  594. local header = msg:GetHeader()
  595. dump(header)
  596. local errorcode = header.param1
  597. if errorcode == 1 then
  598. -- 会话错误
  599. ShowSystemTips(GET_STRING(30009080))
  600. elseif errorcode == 2 then
  601. -- serverID为空
  602. ShowSystemTips(GET_STRING(30009081))
  603. elseif errorcode == 3 then
  604. -- serverID异常
  605. ShowSystemTips(GET_STRING(30009082))
  606. end
  607. local function callback(bType, custom)
  608. if bType == 1 then
  609. self:RequestLoginServer()
  610. elseif bType == 2 then
  611. if global.isWindows then
  612. global.Director:endToLua()
  613. else
  614. global.L_NativeBridgeManager:GN_accountLogout()
  615. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  616. end
  617. end
  618. end
  619. local data = {}
  620. data.str = GET_STRING(30009004)
  621. data.btnDesc = {GET_STRING(30009045), GET_STRING(30009046)}
  622. data.callback = callback
  623. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  624. end
  625. -- step 6. ->520
  626. function LoginProxy:handle_MSG_SC_RESPOINSE_ROLE_INFO(msg)
  627. print( "step 6. local function handle_MSG_SC_RESPOINSE_ROLE_INFO(msg)" )
  628. HideLoadingBar(true)
  629. -- 清除角色信息
  630. self:ClearRoles()
  631. -- headr 第一个:封第一个角色 第二个:封第二个角色
  632. local header = msg:GetHeader()
  633. local banned = {}
  634. banned[1] = (header.recog == 2)
  635. banned[2] = (header.param1 == 2)
  636. -- 禁止自定义取名编辑
  637. self._forbidName = header.param3 == 1
  638. local data = msg:GetData()
  639. local dataLen = msg:GetDataLength()
  640. local cjson = require("cjson")
  641. local jsonStr = data:ReadString(dataLen)
  642. print( jsonStr )
  643. local jsonData = cjson.decode(jsonStr)
  644. -- 无角色
  645. if not jsonData.list or not next(jsonData.list) then
  646. -- global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_Open)
  647. else
  648. local lastIndex = 0
  649. for i, v in ipairs(jsonData.list) do
  650. if i > 2 then
  651. break
  652. end
  653. v.name = v.chr
  654. v.renew = v.relevel
  655. v.ctime = v.create_time or GetServerTime()
  656. v.roleid = v.UserID
  657. v.banned = (v.deny_ip == 1 or v.deny_account == 1 or v.deny_uid == 1)
  658. v.newChar = v.newChar
  659. v.LockChar = v.LockChar
  660. v.deny_msg = v.deny_msg
  661. v.deny_time = v.deny_time
  662. self:AddRole(v)
  663. if v.last == 1 then
  664. lastIndex = i
  665. end
  666. end
  667. if lastIndex > 0 then
  668. self:SetSelectedRoleByIndex(lastIndex)
  669. elseif #jsonData.list >= 1 then
  670. self:SetSelectedRoleByIndex(1)
  671. end
  672. if self._restoreTag then
  673. if #jsonData.list >= 1 then
  674. self:SetSelectedRoleByIndex(2)
  675. else
  676. self:SetSelectedRoleByIndex(1)
  677. end
  678. self._restoreTag = nil
  679. end
  680. end
  681. ---刷新角色数量
  682. local module = global.L_ModuleManager:GetCurrentModule()
  683. local moduleGameEnv = module:GetGameEnv()
  684. local roleData = self._data.roles or {}
  685. if moduleGameEnv.SetRoleCountByServerID then
  686. moduleGameEnv:SetRoleCountByServerID(self:GetSelectedServerId(), #roleData)
  687. end
  688. -- 登录成功
  689. global.Facade:sendNotification(global.NoticeTable.LoginServerSuccess)
  690. -- 数据上报
  691. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  692. local account = AuthProxy:GetUID()
  693. local jData = {}
  694. jData.zoneId = self:GetSelectedServerId()
  695. jData.zoneName = self:GetSelectedServerName()
  696. jData.userId = account
  697. jData.promoteId = tostring(global.L_GameEnvManager:GetGMName())
  698. local DataTrackProxy = global.Facade:retrieveProxy(global.ProxyTable.DataTrackProxy)
  699. DataTrackProxy:OnRoleInfo(jData)
  700. end
  701. --sdk设备信息
  702. function LoginProxy:SendDeviceInfo()
  703. local cjson = require("cjson")
  704. local strData = ""
  705. local boxID = nil
  706. if global.L_GameEnvManager:GetEnvDataByKey("isBoxLogin") == 1 then
  707. local boxBoxGameID = global.L_ModuleManager:GetCurrentModule():GetOperID() or ""
  708. local boxChannelID = global.L_GameEnvManager:GetChannelID() or ""
  709. boxID = boxBoxGameID .. ":" .. boxChannelID
  710. end
  711. local isMac = global.L_GameEnvManager:GetEnvDataByKey("platform") == "mac"
  712. if SL:GetMetaValue("WINPLAYMODE") or isMac then
  713. local DataRePortProxy = global.Facade:retrieveProxy( global.ProxyTable.DataRePortProxy )
  714. local infoData = DataRePortProxy:GetDeviceInfo()
  715. local PCStrData = infoData.device or {}
  716. PCStrData.boxid = boxID
  717. strData = cjson.encode(PCStrData)
  718. else
  719. local deviceInfo = global.L_NativeBridgeManager.GetLoginDataByKey and global.L_NativeBridgeManager:GetLoginDataByKey("deviceInfo") or ""
  720. if deviceInfo and string.len(deviceInfo) > 0 then
  721. local deviceData = cjson.decode(deviceInfo)
  722. if deviceData and next(deviceData) then
  723. deviceData.boxid = boxID
  724. strData = cjson.encode(deviceData)
  725. end
  726. end
  727. end
  728. local jsonString = strData
  729. releasePrint("SendDeviceInfo = "..jsonString)
  730. LuaSendMsg(global.MsgType.MSG_SC_MOBILE_DEVICE_INFO, 0, 0, 0, 0, jsonString, string.len(jsonString))
  731. end
  732. --sdk参数渠道号 appid appkey等
  733. function LoginProxy:SendSDKInfo()
  734. local cjson = require("cjson")
  735. local strData = ""
  736. local isMac = global.L_GameEnvManager:GetEnvDataByKey("platform") == "mac"
  737. if SL:GetMetaValue("WINPLAYMODE") or isMac then
  738. local DataRePortProxy = global.Facade:retrieveProxy( global.ProxyTable.DataRePortProxy )
  739. local infoData = DataRePortProxy:GetDeviceInfo()
  740. local PCStrData = {
  741. sdkver = "1.0.0",
  742. channel = infoData.channel or "",
  743. appid = infoData.appid or "",
  744. appver = global.L_GameEnvManager:GetAPKVersionName() or "",
  745. }
  746. strData = cjson.encode(PCStrData)
  747. else
  748. strData = global.L_NativeBridgeManager.GetLoginDataByKey and global.L_NativeBridgeManager:GetLoginDataByKey("sdkInfo") or ""
  749. end
  750. local jsonString = strData
  751. releasePrint("SendSDKInfo = "..jsonString)
  752. LuaSendMsg(global.MsgType.MSG_SC_MOBILE_SDK_INFO, 0, 0, 0, 0, jsonString, string.len(jsonString))
  753. end
  754. function LoginProxy:CheckBnannedRole(role)
  755. if role and role.banned then
  756. self:ShowBannedRole(role)
  757. return true
  758. end
  759. return false
  760. end
  761. function LoginProxy:ShowBannedRole(role)
  762. local function callback()
  763. end
  764. HideLoadingBar()
  765. -- 封禁客户端自行拼接时间轴,封禁时间 > 15天时不提醒时间
  766. local str = GET_STRING(30009034)
  767. if role.deny_msg and role.deny_msg ~= "" then
  768. str = role.deny_msg
  769. if role.deny_time and role.deny_time > os.time() and role.deny_time - os.time() < 15*24*60*60 then
  770. local date = os.date("*t", role.deny_time)
  771. local timeStr = string.format("%d-%02d-%02d %02d:%02d:%02d", date.year, date.month, date.day, date.hour, date.min, date.sec)
  772. str = str .. "<br>" .. string.format(GET_STRING(30009079), timeStr)
  773. end
  774. end
  775. local data = {}
  776. data.str = str
  777. data.btnDesc = {GET_STRING(1002)}
  778. data.callback = callback
  779. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  780. end
  781. function LoginProxy:RequestCreateRole(name, job, sex)
  782. ShowLoadingBar()
  783. if self.reqCreateRoleScheduleID then
  784. UnSchedule(self.reqCreateRoleScheduleID)
  785. self.reqCreateRoleScheduleID = nil
  786. end
  787. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  788. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  789. local account = AuthProxy:GetUID()
  790. -- login
  791. -- 101 (创建角色) 格式:帐号/角色名/职业/性别/服务器名/主SdkId/子SdkId
  792. -- TODO, sdk id
  793. local cjson = require("cjson")
  794. local jsonData = {}
  795. jsonData.account = account
  796. jsonData.chr = name
  797. jsonData.job = job
  798. jsonData.sex = sex
  799. jsonData.server_name = self:GetSelectedServerId()
  800. jsonData.sdkid = envProxy:GetChannelID()
  801. jsonData.secsdk = "0"
  802. local jsonString = cjson.encode(jsonData)
  803. LuaSendMsg(global.MsgType.MSG_CS_CREATE_ROLE, 0, 0, 0, 0, jsonString, string.len(jsonString))
  804. -- record create info
  805. self._createName = name
  806. self._createJob = job
  807. self._createSex = sex
  808. end
  809. function LoginProxy:handle_MSG_SC_CREATE_ROLE_SUCCESS(msg)
  810. HideLoadingBar()
  811. local data = msg:GetData()
  812. local dataLen = msg:GetDataLength()
  813. local dataStr = data:ReadString(dataLen)
  814. local slices = string.split(dataStr, "/")
  815. local roleName = slices[1]
  816. local role = {}
  817. role.roleid = slices[2]
  818. role.name = roleName
  819. role.level = 1
  820. role.job = self._createJob
  821. role.sex = self._createSex
  822. role.ctime = GetServerTime()
  823. self:AddRole(role)
  824. self:SetSelectedRole(role)
  825. -- clear create info
  826. self._createName = nil
  827. self._createJob = nil
  828. self._createSex = nil
  829. -- go
  830. self:RequestEnterGame()
  831. -- Data recording
  832. local AuthProxy = global.Facade:retrieveProxy( global.ProxyTable.AuthProxy )
  833. local jData = {}
  834. jData.zoneId = self:GetSelectedServerId()
  835. jData.zoneName = self:GetSelectedServerName()
  836. jData.roleId = self:GetSelectedRoleID()
  837. jData.roleName = self:GetSelectedRoleName()
  838. jData.roleCTime = role.ctime
  839. jData.roleLevel = "1"
  840. jData.roleVIPLev = "0"
  841. jData.roleBalance = "0"
  842. jData.roleGuild = ""
  843. jData.userId = tostring( AuthProxy:GetUID() )
  844. jData.reinLevel = "0"
  845. jData.promoteId = tostring(global.L_GameEnvManager:GetGMName())
  846. jData.roleJobName = GetJobName(role.job)
  847. jData.roleJobId = role.job
  848. jData.roleAtt = 0
  849. -- 新增 主服id和主服name
  850. local selSerInfo = self:GetSelectedServer()
  851. local main_servid = selSerInfo and selSerInfo.mainServerId
  852. local main_server_name = selSerInfo and selSerInfo.mainServerName
  853. jData.main_servid = main_servid
  854. jData.main_server_name = main_server_name
  855. local DataTrackProxy = global.Facade:retrieveProxy( global.ProxyTable.DataTrackProxy )
  856. DataTrackProxy:OnCreateRole(jData)
  857. ---刷新角色数量
  858. local module = global.L_ModuleManager:GetCurrentModule()
  859. local moduleGameEnv = module:GetGameEnv()
  860. local roleData = self._data.roles or {}
  861. if moduleGameEnv.SetRoleCountByServerID then
  862. moduleGameEnv:SetRoleCountByServerID(self:GetSelectedServerId(), #roleData)
  863. end
  864. end
  865. function LoginProxy:handle_MSG_SC_CREATE_ROLE_FAIL(msg)
  866. HideLoadingBar(true)
  867. local head = msg:GetHeader()
  868. if head.recog == -10 then
  869. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009035))
  870. elseif head.recog == -11 then
  871. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009036))
  872. elseif head.recog == 5 then
  873. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009070))
  874. elseif head.recog == 6 then
  875. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009071))
  876. elseif head.recog == 7 then
  877. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009072))
  878. elseif head.recog == 100 or head.recog == 101 or head.recog == 102 or head.recog == 103 then
  879. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009000+head.recog))
  880. else
  881. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009016 + head.recog))
  882. end
  883. end
  884. function LoginProxy:RequestDeleteRole(uid)
  885. dump(uid)
  886. ShowLoadingBar()
  887. local sendStr = uid
  888. LuaSendMsg(global.MsgType.MSG_CS_DELETE_ROLE, 0, 0, 0, 0, sendStr, string.len(sendStr))
  889. end
  890. function LoginProxy:handle_MSG_SC_DELETE_ROLE_SUCCESS(msg)
  891. HideLoadingBar(true)
  892. -- del
  893. self:DelRoleByID(self:GetSelectedRoleID())
  894. -- select
  895. local roles = self:GetRoles()
  896. if #roles == 0 then
  897. self:SetSelectedRole(nil)
  898. else
  899. self:SetSelectedRoleByIndex(1)
  900. end
  901. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009014))
  902. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_Update)
  903. ---刷新角色数量
  904. local module = global.L_ModuleManager:GetCurrentModule()
  905. local moduleGameEnv = module:GetGameEnv()
  906. local roleData = self._data.roles or {}
  907. if moduleGameEnv.SetRoleCountByServerID then
  908. moduleGameEnv:SetRoleCountByServerID(self:GetSelectedServerId(), #roleData)
  909. end
  910. end
  911. function LoginProxy:handle_MSG_SC_DELETE_ROLE_FAIL(msg)
  912. HideLoadingBar(true)
  913. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(30009015))
  914. end
  915. function LoginProxy:RequestRestoreRoleInfo()
  916. self._data.restoreRoleDatas = {}
  917. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  918. local account = tostring(AuthProxy:GetUID())
  919. LuaSendMsg(global.MsgType.MSG_CS_RESTORE_ROLE_LIST, 0, 0, 0, 0, account, string.len(account))
  920. end
  921. function LoginProxy:handle_MSG_SC_RESTORE_ROLE_LIST(msg)
  922. -- 558[{uid,uname,ulevel},{uid,uname,ulevel},]
  923. local jsonData = ParseRawMsgToJson(msg)
  924. if not jsonData then
  925. return nil
  926. end
  927. for _,v in pairs(jsonData) do
  928. table.insert(self._data.restoreRoleDatas, v)
  929. end
  930. if #self._data.restoreRoleDatas == 0 then
  931. SL:ShowSystemTips("你没有可以恢复的角色!")
  932. return false
  933. end
  934. global.Facade:sendNotification(global.NoticeTable.Refresh_RestoreRole_UI)
  935. end
  936. function LoginProxy:getRestoreRoleDatas()
  937. return self._data.restoreRoleDatas
  938. end
  939. function LoginProxy:RequestRestoreRole(data)
  940. local sendStr = data.uid .. "/" .. data.uname
  941. LuaSendMsg(global.MsgType.MSG_CS_RESTORE_ROLE, 0, 0, 0, 0, sendStr, string.len(sendStr))
  942. releasePrint("request restore role", sendStr)
  943. end
  944. function LoginProxy:handle_MSG_SC_RESTORE_ROLE(msg)
  945. -- 559 Recog
  946. -- -1禁止恢复
  947. -- 0恢复失败
  948. -- >0恢复成功
  949. local header = msg:GetHeader()
  950. if header.recog == -1 then
  951. ShowSystemTips(GET_STRING(30009090))
  952. elseif header.recog == 0 then
  953. ShowSystemTips(GET_STRING(30009091))
  954. elseif header.recog > 0 then
  955. ShowSystemTips(GET_STRING(30009092))
  956. self._restoreTag = 1
  957. local specialData = self:GetNetMsgSpecialData()
  958. self:RequestRoleInfo(specialData)
  959. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_RestoreSuccess)
  960. end
  961. releasePrint("restore role resp", header.recog)
  962. end
  963. -- step 7. 103->
  964. function LoginProxy:RequestEnterGame()
  965. -- debug
  966. releasePrint("step 7")
  967. ShowLoadingBar()
  968. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  969. local account = AuthProxy:GetUID()
  970. local roleName = self:GetSelectedRoleName()
  971. local sendStr = string.format("%s/%s", account, roleName)
  972. LuaSendMsg(global.MsgType.MSG_CS_SELECT_ROLE, 0, 0, 0, 0, sendStr, string.len(sendStr))
  973. end
  974. -- step 8. ->525
  975. function LoginProxy:handle_MSG_SC_GAMESERVER_INFO(msg)
  976. -- debug
  977. releasePrint("step 8. 525 handle_MSG_SC_GAMESERVER_INFO")
  978. HideLoadingBar()
  979. local data = msg:GetData()
  980. local dataStr = data:ReadString(msg:GetDataLength())
  981. local slices = string.split(dataStr, "/")
  982. local ip = tostring(slices[1])
  983. local port = tonumber(slices[2])
  984. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  985. local account = AuthProxy:GetUID()
  986. self:SetGameServerPort(port)
  987. local ip = self:GetSelectedServerIp()
  988. local proxyport = self:GetSelectedServerProxyPort()
  989. local connectIP = tostring(ip)
  990. local connectPort = tonumber(proxyport or port)
  991. -- // Disconnect current server and connect new server
  992. local errorTips = (connectPort == nil and 0) or (connectPort == 0 and 1) or nil
  993. if errorTips then
  994. ShowSystemTips(string.format(GET_STRING(30009300), errorTips))
  995. end
  996. local netClient = global.gameEnvironment:GetNetClient()
  997. netClient:Disconnect()
  998. local Connect = function (param1Ex)
  999. local ret = netClient:Connect(connectIP, connectPort)
  1000. releasePrint("525, connect", connectIP, connectPort, ret)
  1001. if 1 ~= ret then
  1002. -- TODO, tips 游戏世界
  1003. return
  1004. end
  1005. -- 20消息
  1006. -- // *#账号/角色名字/角色ID/parma4/920080512/channelid/whitelist
  1007. -- channelid 渠道号 string
  1008. -- whitelist 白名单 1/0 1.白名单 0.非白名单
  1009. local currentModule = global.L_ModuleManager:GetCurrentModule()
  1010. local moduleGameEnv = currentModule:GetGameEnv()
  1011. local whitelist = (moduleGameEnv:IsWhitelist() == true and 1 or 0)
  1012. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  1013. local cert = global.L_NativeBridgeManager.GetCertification and global.L_NativeBridgeManager:GetCertification()
  1014. local adult = global.L_NativeBridgeManager.GetAdult and global.L_NativeBridgeManager:GetAdult()
  1015. cert = (cert == true) and 1 or 0
  1016. adult = (adult == true) and 1 or 0
  1017. local isboxlogin = global.L_GameEnvManager:GetEnvDataByKey("isBoxLogin") or 0
  1018. local isBatchMsg = (global.LuaBridgeCtl:GetModulesSwitch(global.MMO.Modules_Index_Net_BatchMsg) == 1) and 1 or 0
  1019. -- android:0, ios:1 except:2
  1020. local platform = 2
  1021. if cc.PLATFORM_OS_ANDROID == global.Platform or global.isOHOS then
  1022. platform = 0
  1023. elseif cc.PLATFORM_OS_IPAD == global.Platform or cc.PLATFORM_OS_IPHONE == global.Platform then
  1024. platform = 1
  1025. end
  1026. local sendStr = string.format("*#%s/%s/%s/%d/%s/0/%s/%s/%s/%s/%s/%s",
  1027. account,
  1028. self:GetSelectedRoleName(),
  1029. self:GetSelectedRoleID(),
  1030. netClient:GetNetMessageTypeSData(),
  1031. platform, --920080512 改 platform参数
  1032. envProxy:GetChannelID(),
  1033. whitelist,
  1034. cert,
  1035. adult,
  1036. isboxlogin,
  1037. isBatchMsg
  1038. )
  1039. print("+++++++++++++++++MSG_CS_LOGIN_SERVER:", sendStr )
  1040. local recog = GET_NET_MSG_STAMP_HEAD_RECOG()
  1041. local param1 = param1Ex or GET_NET_MSG_STAMP_HEAD_PARAM1()
  1042. local param2 = tonumber(self:GetMainSelectedServerId() or self:GetSelectedServerId()) or 0
  1043. local param3 = tonumber(self:GetGameServerPort()) or 0
  1044. LuaSendMsg(global.MsgType.MSG_CS_LOGIN_SERVER, recog, param1, param2, param3, sendStr, string.len(sendStr))
  1045. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  1046. AuthProxy:RequestDecodeJWTToServer()
  1047. -- 小退后 后端需要间隔处理连接 (200ms
  1048. PerformWithDelayGlobal(function()
  1049. AuthProxy:RequestQQDawankaInfo()
  1050. end, 0.20)
  1051. AuthProxy:RequestRenewalQQOpenKey(true)
  1052. --公告超时
  1053. global.Facade:sendNotification(global.NoticeTable.GameWorldLoadinTipsTimeout)
  1054. end
  1055. if proxyport then
  1056. GET_NET_MSG_STAMP_HEAD_PARAM1_NEW(function (param1Ex)
  1057. Connect(param1Ex)
  1058. LoginProxy.param1Ex = nil
  1059. end)
  1060. else
  1061. Connect()
  1062. end
  1063. end
  1064. -- step 8. ->526
  1065. function LoginProxy:handle_MSG_SC_GAMESERVER_INFO_ERROR(msg)
  1066. -- debug
  1067. releasePrint("step 8. 526 handle_MSG_SC_GAMESERVER_INFO_ERROR")
  1068. HideLoadingBar()
  1069. -- nRecog = 99 标识服务器隐藏 或者 维护 不在名单内不能进
  1070. local descStr = GET_STRING(30009003)
  1071. local header = msg:GetHeader()
  1072. if header.recog == 99 then
  1073. descStr = GET_STRING(30009106)
  1074. end
  1075. --
  1076. local function callback(bType, custom)
  1077. if global.isWindows then
  1078. global.Director:endToLua()
  1079. else
  1080. global.L_NativeBridgeManager:GN_accountLogout()
  1081. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  1082. end
  1083. end
  1084. local data = {}
  1085. data.str = descStr .. "[526]"
  1086. data.btnDesc = { GET_STRING(30009046)}
  1087. data.callback = callback
  1088. data.hideCloseBtn = true
  1089. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1090. end
  1091. -- step 9. 1018->
  1092. function LoginProxy:EnterWorld(isReconnect)
  1093. local envProxy = global.Facade:retrieveProxy(global.ProxyTable.GameEnvironment)
  1094. local currModule = global.L_ModuleManager:GetCurrentModule()
  1095. local GameConfigMgrProxy = global.Facade:retrieveProxy(global.ProxyTable.GameConfigMgrProxy)
  1096. local contentFix = GameConfigMgrProxy:getContentFix()
  1097. local jsonData = contentFix
  1098. jsonData.gameid = currModule:GetOperID()
  1099. jsonData.channelId = envProxy:GetChannelID()
  1100. jsonData.packageName = envProxy:GetAPKPackageName()
  1101. jsonData.tripartite = global.OtherTradingBank and 1 or 0
  1102. local sendJson = cjson.encode( jsonData )
  1103. local visibleSize = global.Director:getVisibleSize()
  1104. local screenwidth = visibleSize.width
  1105. local screenheight = visibleSize.height
  1106. local devicecode = self:GetDeviceCode()
  1107. local platform = global.OperatingMode
  1108. local connectV = isReconnect and 1 or 0
  1109. local isEMU = global.L_GameEnvManager:IsEmulator() and 1 or 0
  1110. local param2 = Merge16Bit(connectV, isEMU)
  1111. local param3 = Merge16Bit(screenwidth, screenheight)
  1112. LuaSendMsg(global.MsgType.MSG_CS_ENTER_GAME_DUMMY, platform, param2, param3, devicecode, sendJson, string.len(sendJson))
  1113. -- debug
  1114. releasePrint("step 9", os.date(), platform, param2, param3, devicecode, sendJson)
  1115. end
  1116. function LoginProxy:SaveDeviceCode(code) --本地储存devicecode
  1117. local userData = UserData:new("ContentFix")
  1118. userData:setStringForKey("devicecode", code)
  1119. end
  1120. function LoginProxy:GetDeviceCode() --获取devicecode
  1121. local userData = UserData:new("ContentFix")
  1122. local code = userData:getStringForKey("devicecode", "")
  1123. if code == "" or code == nil then
  1124. code = 0
  1125. end
  1126. print(code,"devicecode")
  1127. return code
  1128. end
  1129. function LoginProxy:RequestRoleName(job, sex)
  1130. ShowLoadingBar(3)
  1131. LuaSendMsg(global.MsgType.MSG_CS_ROLE_NAME, job, sex)
  1132. end
  1133. function LoginProxy:handle_MSG_SC_ROLE_NAME(msg)
  1134. HideLoadingBar()
  1135. local len = msg:GetDataLength()
  1136. if len <= 0 then
  1137. return nil
  1138. end
  1139. local msgData = msg:GetData()
  1140. local sliceStr = msgData:ReadString(len)
  1141. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_RandNameResp, sliceStr)
  1142. end
  1143. function LoginProxy:RequestLeaveWorldNotify()
  1144. -- 小退要发送一个消息给服务器
  1145. LuaSendMsg(global.MsgType.MSG_CS_REBACK_TO_ROLE)
  1146. end
  1147. function LoginProxy:RequestSoftClose()
  1148. -- 请求小退 服务器返回可以小退才能小退
  1149. LuaSendMsg(global.MsgType.MSG_CS_QURYSOFTCLOSE)
  1150. end
  1151. function LoginProxy:handle_MSG_SC_SERVER_FORBIDDEN(msg)
  1152. releasePrint("step 10 handle_MSG_SC_SERVER_FORBIDDEN")
  1153. local function callback(bType, custom)
  1154. if global.isWindows then
  1155. global.Director:endToLua()
  1156. else
  1157. global.L_NativeBridgeManager:GN_accountLogout()
  1158. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  1159. end
  1160. end
  1161. local data = {}
  1162. data.str = GET_STRING(30009053)
  1163. data.btnDesc = { GET_STRING(30009046)}
  1164. data.callback = callback
  1165. data.hideCloseBtn = true
  1166. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1167. -- 重连禁用
  1168. global.Facade:sendNotification(global.NoticeTable.ReconnectForbidden)
  1169. end
  1170. function LoginProxy:handle_MSG_SC_SERVER_FORBIDDEN_NET_ERROR(msg)
  1171. releasePrint("step 10 handle_MSG_SC_SERVER_FORBIDDEN_NET_ERROR")
  1172. -- 重连禁用
  1173. global.Facade:sendNotification(global.NoticeTable.ReconnectForbidden)
  1174. -- 不弹提醒
  1175. local header = msg:GetHeader()
  1176. if header.recog == 1 then
  1177. return
  1178. end
  1179. local function callback(bType, custom)
  1180. -- PC上默认退出,方便获取新的登录信息以及更新exe
  1181. if global.isWindows then
  1182. global.Director:endToLua()
  1183. else
  1184. global.L_NativeBridgeManager:GN_accountLogout()
  1185. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  1186. end
  1187. end
  1188. local data = {}
  1189. data.str = GET_STRING(30009061)
  1190. data.btnDesc = { GET_STRING(30009046)}
  1191. data.callback = callback
  1192. data.hideCloseBtn = true
  1193. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1194. end
  1195. --小退
  1196. function LoginProxy:handle_MSG_SC_REBACK_TO_ROLE(msg)
  1197. -- body
  1198. local jsonData = ParseRawMsgToJson(msg)
  1199. if not jsonData then
  1200. return
  1201. end
  1202. if jsonData.SoftCloseSuccess == 1 then
  1203. if self:GetSelectedRoleID() == jsonData.UserID then --小退处理
  1204. global.gameWorldController:OnGameLeaveWorld()
  1205. end
  1206. else
  1207. global.Facade:sendNotification( global.NoticeTable.SystemTips, GET_STRING(310000100) )
  1208. end
  1209. end
  1210. -- 2020->
  1211. function LoginProxy:SyncVersion(needFilter)
  1212. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  1213. local currModule = global.L_ModuleManager:GetCurrentModule()
  1214. local account = AuthProxy:GetUID()
  1215. local resOriginVer = currModule:GetOriginVersion()
  1216. local resRemoteVer = currModule:GetRemoteVersion()
  1217. local sdkuid = global.L_NativeBridgeManager:GetSdkuid() or global.L_NativeBridgeManager:GetUsername() or account
  1218. local isBoxLogin = global.L_GameEnvManager:GetEnvDataByKey("isBoxLogin") == 1 --盒子登录
  1219. local hasBuf = global.L_NativeBridgeManager:GetHasBuff() or "0"
  1220. local versionCode = global.L_GameEnvManager:GetAPKVersionCode()
  1221. versionCode = isBoxLogin and tonumber(versionCode) + 1000 or versionCode
  1222. local channelID = global.L_GameEnvManager:GetChannelID()
  1223. local hasNp = tostring(SL:GetMetaValue("PC_NP_STATUS") and 1 or 0)
  1224. local is996cloudDevice = tostring(SL:GetMetaValue("996_CLOUD_DEVICE") and 1 or 0)
  1225. local sendStr = string.format("%s/%s/%s/%s/%s/%s/%s/%s/%s", account, resOriginVer, resRemoteVer, tostring(sdkuid), hasBuf, versionCode, channelID, hasNp,
  1226. is996cloudDevice)
  1227. local sendLen = string.len(sendStr)
  1228. local recog = needFilter and 1 or 0 -- 是否需要过滤部分消息
  1229. releasePrint("sync version:" .. sendStr, recog)
  1230. LuaSendMsg(global.MsgType.MSG_CS_SYNC_VERSION, recog, 0, 0, 0, sendStr, sendLen)
  1231. end
  1232. function LoginProxy:unScheduleServerList()
  1233. if self.reqServerListScheduleID then
  1234. UnSchedule(self.reqServerListScheduleID)
  1235. self.reqServerListScheduleID = nil
  1236. end
  1237. end
  1238. function LoginProxy:connectTimeOutTips()
  1239. local function callback(bType)
  1240. if bType == 1 then
  1241. -- PC上默认退出,方便获取新的登录信息以及更新exe
  1242. if global.isWindows then
  1243. global.Director:endToLua()
  1244. else
  1245. global.L_NativeBridgeManager:GN_accountLogout()
  1246. global.Facade:sendNotification( global.NoticeTable.RestartGame )
  1247. end
  1248. end
  1249. end
  1250. local data = {}
  1251. data.str = GET_STRING(600003000)
  1252. data.btnDesc = {GET_STRING(600003001)}
  1253. data.callback = callback
  1254. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1255. end
  1256. --服务器返回失败弹窗
  1257. function LoginProxy:handle_MSG_SC_SERVICE_FAIL_TIPS( msg )
  1258. HideLoadingBar()
  1259. -- body
  1260. local header = msg:GetHeader()
  1261. local msgLen = msg:GetDataLength()
  1262. local tipStr = msgLen > 0 and msg:GetData():ReadString(msgLen) or ""
  1263. local exitType = header.recog or 0
  1264. -- recog: 0 正常提示 1 退出到登录界面 2 闪退
  1265. local function callback(bType, custom)
  1266. if exitType == 1 then
  1267. global.L_NativeBridgeManager:GN_accountLogout()
  1268. global.Facade:sendNotification(global.NoticeTable.RestartGame)
  1269. elseif exitType == 2 then
  1270. global.Director:endToLua()
  1271. end
  1272. end
  1273. local data = {}
  1274. data.str = tipStr
  1275. data.btnDesc = { GET_STRING(1002)}
  1276. data.callback = callback
  1277. data.hideCloseBtn = true
  1278. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  1279. releasePrint("global.MsgType.MSG_SC_SERVICE_FAIL_TIPS 6800", tipStr, exitType)
  1280. end
  1281. function LoginProxy:handle_MSG_SC_SERVICE_NEW_LIMIT_IMG(msg)
  1282. -- body
  1283. HideLoadingBar()
  1284. self._isNewLimit = true
  1285. local msgLen = msg:GetDataLength()
  1286. local msgHdr = msg:GetHeader()
  1287. local recog = msgHdr.recog
  1288. release_print("global.MsgType.MSG_SC_SERVICE_FAIL_TIPS 6801", recog)
  1289. -- 下发图片验证
  1290. if recog == 0 then
  1291. local dataString = msgLen > 0 and msg:GetData():ReadString(msgLen) or ""
  1292. local jsonData = {}
  1293. local function callback(inputStr)
  1294. local sendInputStr = Encode6BitBuf(inputStr, string.len(inputStr))
  1295. LuaSendMsg(global.MsgType.MSG_CS_SERVICE_NEW_LIMIT_IMG, 0, 0, 0, 0, sendInputStr, string.len(sendInputStr))
  1296. end
  1297. -- 刷新图片
  1298. local function updateCallback()
  1299. LuaSendMsg(global.MsgType.MSG_CS_SERVICE_NEW_LIMIT_IMG, 1, 0, 0, 0)
  1300. end
  1301. jsonData.Img = dataString
  1302. jsonData.callback = callback
  1303. jsonData.updateCallback = updateCallback
  1304. global.Facade:sendNotification(global.NoticeTable.LimitVerificationLayer_Open, jsonData)
  1305. elseif recog == 1 then
  1306. ShowSystemTips(GET_STRING(310001201))
  1307. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Close, data)
  1308. global.Facade:sendNotification(global.NoticeTable.LimitVerificationLayer_Close)
  1309. -- 重新发送创角
  1310. self.reqCreateRoleScheduleID = PerformWithDelayGlobal(function()
  1311. self.reqCreateRoleScheduleID = nil
  1312. self:RequestCreateRole(self._createName, self._createJob, self._createSex)
  1313. end, 0.1)
  1314. elseif recog == -1 then
  1315. ShowSystemTips(GET_STRING(310001200))
  1316. end
  1317. end
  1318. function LoginProxy:handle_MSG_SC_SERVICE_NEW_LIMIT_IMG1(msg)
  1319. -- body
  1320. HideLoadingBar()
  1321. self._isNewLimit = true
  1322. local msgLen = msg:GetDataLength()
  1323. local msgHdr = msg:GetHeader()
  1324. local recog = msgHdr.recog
  1325. release_print("global.MsgType.MSG_SC_SERVICE_FAIL_TIPS 6811", recog)
  1326. -- 下发图片验证
  1327. if recog == 0 then
  1328. self:unScheduleServerList()
  1329. local dataString = msgLen > 0 and msg:GetData():ReadString(msgLen) or ""
  1330. local jsonData = {}
  1331. local function callback(inputStr)
  1332. local sendInputStr = Encode6BitBuf(inputStr, string.len(inputStr))
  1333. LuaSendMsg(global.MsgType.MSG_CS_SERVICE_NEW_LIMIT_IMG1, 0, 0, 0, 0, sendInputStr, string.len(sendInputStr))
  1334. end
  1335. -- 刷新图片
  1336. local function updateCallback()
  1337. LuaSendMsg(global.MsgType.MSG_CS_SERVICE_NEW_LIMIT_IMG1, 1, 0, 0, 0)
  1338. end
  1339. jsonData.Img = dataString
  1340. jsonData.callback = callback
  1341. jsonData.updateCallback = updateCallback
  1342. global.Facade:sendNotification(global.NoticeTable.LimitVerificationLayer_Open, jsonData)
  1343. elseif recog == 1 then
  1344. ShowSystemTips(GET_STRING(310001201))
  1345. self._isNewLimit = false
  1346. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Close, data)
  1347. global.Facade:sendNotification(global.NoticeTable.LimitVerificationLayer_Close)
  1348. -- 发送 2001
  1349. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  1350. local uid = AuthProxy:GetUID()
  1351. local token = AuthProxy:GetToken()
  1352. -- for debug mode, login whitelist
  1353. if global.isDebugMode then
  1354. token = "sJAsOn001"
  1355. end
  1356. self:send_MSG_CS_REQUEST_SERVER_LIST(uid, token, LoginProxy.param1Ex)
  1357. elseif recog == -1 then
  1358. ShowSystemTips(GET_STRING(310001200))
  1359. end
  1360. end
  1361. function LoginProxy:RegisterMsgHandler()
  1362. LoginProxy.super.RegisterMsgHandler(self)
  1363. local msgType = global.MsgType
  1364. LuaRegisterMsgHandler(msgType.MSG_SC_RESPONSE_SERVER_LIST, handler(self, self.handle_MSG_SC_RESPONSE_SERVER_LIST))
  1365. LuaRegisterMsgHandler(msgType.MSG_SC_RESPONSE_SERVER_INFO, handler(self, self.handle_MSG_SC_RESPONSE_SERVER_INFO))
  1366. LuaRegisterMsgHandler(msgType.MSG_SC_CREATE_ROLE_SUCCESS, handler(self, self.handle_MSG_SC_CREATE_ROLE_SUCCESS))
  1367. LuaRegisterMsgHandler(msgType.MSG_SC_CREATE_ROLE_FAIL, handler(self, self.handle_MSG_SC_CREATE_ROLE_FAIL))
  1368. LuaRegisterMsgHandler(msgType.MSG_SC_DELETE_ROLE_SUCCESS, handler(self, self.handle_MSG_SC_DELETE_ROLE_SUCCESS))
  1369. LuaRegisterMsgHandler(msgType.MSG_SC_DELETE_ROLE_FAIL, handler(self, self.handle_MSG_SC_DELETE_ROLE_FAIL))
  1370. LuaRegisterMsgHandler(msgType.MSG_SC_RESTORE_ROLE_LIST, handler(self, self.handle_MSG_SC_RESTORE_ROLE_LIST))
  1371. LuaRegisterMsgHandler(msgType.MSG_SC_RESTORE_ROLE, handler(self, self.handle_MSG_SC_RESTORE_ROLE))
  1372. LuaRegisterMsgHandler(msgType.MSG_SC_RESPOINSE_ROLE_INFO, handler(self, self.handle_MSG_SC_RESPOINSE_ROLE_INFO))
  1373. LuaRegisterMsgHandler(msgType.MSG_SC_RESPOINSE_ROLE_INFO_FAIL, handler(self, self.handle_MSG_SC_RESPOINSE_ROLE_INFO_FAIL))
  1374. LuaRegisterMsgHandler(msgType.MSG_SC_GAMESERVER_INFO, handler(self, self.handle_MSG_SC_GAMESERVER_INFO))
  1375. LuaRegisterMsgHandler(msgType.MSG_SC_GAMESERVER_INFO_ERROR, handler(self, self.handle_MSG_SC_GAMESERVER_INFO_ERROR))
  1376. LuaRegisterMsgHandler(msgType.MSG_SC_ROLE_NAME, handler(self, self.handle_MSG_SC_ROLE_NAME))
  1377. LuaRegisterMsgHandler(msgType.MSG_SC_SERVER_FORBIDDEN, handler(self, self.handle_MSG_SC_SERVER_FORBIDDEN))
  1378. LuaRegisterMsgHandler(msgType.MSG_SC_SERVER_FORBIDDEN_NET_ERROR, handler(self, self.handle_MSG_SC_SERVER_FORBIDDEN_NET_ERROR))
  1379. LuaRegisterMsgHandler(msgType.MSG_SC_RESPOINSE_CHECK_TOKEN_FAIL, handler(self, self.handle_MSG_SC_RESPOINSE_CHECK_TOKEN_FAIL))
  1380. LuaRegisterMsgHandler(msgType.MSG_SC_REBACK_TO_ROLE, handler(self,self.handle_MSG_SC_REBACK_TO_ROLE)) --小退是否成功数据
  1381. LuaRegisterMsgHandler(msgType.MSG_SC_SERVICE_FAIL_TIPS, handler(self,self.handle_MSG_SC_SERVICE_FAIL_TIPS)) --服务器返回失败弹窗
  1382. LuaRegisterMsgHandler(msgType.MSG_SC_SERVICE_NEW_LIMIT_IMG, handler(self,self.handle_MSG_SC_SERVICE_NEW_LIMIT_IMG)) --图片验证码
  1383. LuaRegisterMsgHandler(msgType.MSG_SC_SERVICE_NEW_LIMIT_IMG1, handler(self,self.handle_MSG_SC_SERVICE_NEW_LIMIT_IMG1)) --图片验证码 网关
  1384. end
  1385. return LoginProxy