UpLevelHandler.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "upLevelHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------UpLevelHandler-------------------------------
  12. Pomelo.UpLevelHandler = {}
  13. local function upInfoRequestEncoder(msg)
  14. local input = upLevelHandler_pb.UpInfoRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function upInfoRequestDecoder(stream)
  19. local res = upLevelHandler_pb.UpInfoResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.UpLevelHandler.upInfoRequest(cb,option)
  24. local input = nil
  25. Socket.OnRequestStart("area.upLevelHandler.upInfoRequest", option)
  26. Socket.Request("area.upLevelHandler.upInfoRequest", input, function(res)
  27. if(res.s2c_code == 200) then
  28. Pomelo.UpLevelHandler.lastUpInfoResponse = res
  29. Socket.OnRequestEnd("area.upLevelHandler.upInfoRequest", true)
  30. cb(nil,res)
  31. else
  32. local ex = {}
  33. if(res.s2c_code) then
  34. ex.Code = res.s2c_code
  35. ex.Message = res.s2c_msg
  36. else
  37. ex.Code = 501
  38. ex.Message = "[LuaXmdsNetClient] area.upLevelHandler.upInfoRequest decode error!!"
  39. end
  40. Socket.OnRequestEnd("area.upLevelHandler.upInfoRequest", false,ex.Code,ex.Message)
  41. cb(ex,nil)
  42. end
  43. end, upInfoRequestEncoder, upInfoRequestDecoder)
  44. end
  45. local function upLevelRequestEncoder(msg)
  46. local input = upLevelHandler_pb.UpLevelRequest()
  47. protobuf.FromMessage(input,msg)
  48. return (input:SerializeToString())
  49. end
  50. local function upLevelRequestDecoder(stream)
  51. local res = upLevelHandler_pb.UpLevelResponse()
  52. res:ParseFromString(stream)
  53. return res
  54. end
  55. function Pomelo.UpLevelHandler.upLevelRequest(cb,option)
  56. local input = nil
  57. Socket.OnRequestStart("area.upLevelHandler.upLevelRequest", option)
  58. Socket.Request("area.upLevelHandler.upLevelRequest", input, function(res)
  59. if(res.s2c_code == 200) then
  60. Pomelo.UpLevelHandler.lastUpLevelResponse = res
  61. Socket.OnRequestEnd("area.upLevelHandler.upLevelRequest", true)
  62. cb(nil,res)
  63. else
  64. local ex = {}
  65. if(res.s2c_code) then
  66. ex.Code = res.s2c_code
  67. ex.Message = res.s2c_msg
  68. else
  69. ex.Code = 501
  70. ex.Message = "[LuaXmdsNetClient] area.upLevelHandler.upLevelRequest decode error!!"
  71. end
  72. Socket.OnRequestEnd("area.upLevelHandler.upLevelRequest", false,ex.Code,ex.Message)
  73. cb(ex,nil)
  74. end
  75. end, upLevelRequestEncoder, upLevelRequestDecoder)
  76. end
  77. --------------------------------Pomelo-------------------------------
  78. return Pomelo