VerificationProxy.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local VerificationProxy = class("VerificationProxy", RemoteProxy)
  3. VerificationProxy.NAME = global.ProxyTable.VerificationProxy
  4. local cjson = require("cjson")
  5. function VerificationProxy:ctor()
  6. VerificationProxy.super.ctor(self)
  7. end
  8. function VerificationProxy:onRegister()
  9. VerificationProxy.super.onRegister(self)
  10. end
  11. function VerificationProxy:handle_MSG_SC_IMG_VERIFICATION(msg)
  12. local msgLen = msg:GetDataLength()
  13. local msgHdr = msg:GetHeader()
  14. local time = msgHdr.recog
  15. local dataString = msg:GetData():ReadString(msgLen)
  16. local jsonData = {}
  17. local imgs = string.split(dataString, "&")
  18. jsonData.bgImg = imgs[1]
  19. jsonData.Img = imgs[2]
  20. jsonData.time = time
  21. global.Facade:sendNotification(global.NoticeTable.VerificationLayer_Open, jsonData)
  22. end
  23. function VerificationProxy:handle_MSG_SC_IMG_VERIFICATION_RESULT(msg)
  24. local msgHdr = msg:GetHeader()
  25. dump(msgHdr, "msgHdr___")
  26. if msgHdr.recog == 1 then --成功了
  27. HideLoadingBar()
  28. global.Facade:sendNotification(global.NoticeTable.VerificationLayer_Close)
  29. elseif msgHdr.recog >= 3 then --次数到了 gg
  30. HideLoadingBar()
  31. global.Facade:sendNotification(global.NoticeTable.VerificationLayer_Close)
  32. -- 重连禁用
  33. global.Facade:sendNotification(global.NoticeTable.ReconnectForbidden)
  34. local function callback(bType, custom)
  35. global.L_NativeBridgeManager:GN_accountLogout()
  36. global.Facade:sendNotification(global.NoticeTable.RestartGame)
  37. end
  38. local data = {}
  39. data.str = GET_STRING(30009061)
  40. data.btnDesc = { GET_STRING(30009046) }
  41. data.callback = callback
  42. data.hideCloseBtn = true
  43. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  44. end
  45. end
  46. function VerificationProxy:sendPos(x, y)
  47. dump({ x, y }, "sendPos")
  48. LuaSendMsg(global.MsgType.MSG_CS_IMG_VERIFICATION_POS, x, y)
  49. end
  50. function VerificationProxy:RegisterMsgHandler()
  51. local msgType = global.MsgType
  52. LuaRegisterMsgHandler(msgType.MSG_SC_IMG_VERIFICATION, handler(self, self.handle_MSG_SC_IMG_VERIFICATION))--下发的验证图片
  53. LuaRegisterMsgHandler(msgType.MSG_SC_IMG_VERIFICATION_RESULT, handler(self, self.handle_MSG_SC_IMG_VERIFICATION_RESULT))--验证结果
  54. end
  55. return VerificationProxy