RichHandler.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "richHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------RichHandler-------------------------------
  12. Pomelo.RichHandler = {}
  13. local function getRichInfoRequestEncoder(msg)
  14. local input = richHandler_pb.GetRichInfoRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function getRichInfoRequestDecoder(stream)
  19. local res = richHandler_pb.GetRichInfoResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.RichHandler.getRichInfoRequest(cb,option)
  24. local input = nil
  25. Socket.OnRequestStart("rich.richHandler.getRichInfoRequest", option)
  26. Socket.Request("rich.richHandler.getRichInfoRequest", input, function(res)
  27. if(res.s2c_code == 200) then
  28. Pomelo.RichHandler.lastGetRichInfoResponse = res
  29. Socket.OnRequestEnd("rich.richHandler.getRichInfoRequest", 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] rich.richHandler.getRichInfoRequest decode error!!"
  39. end
  40. Socket.OnRequestEnd("rich.richHandler.getRichInfoRequest", false,ex.Code,ex.Message)
  41. cb(ex,nil)
  42. end
  43. end, getRichInfoRequestEncoder, getRichInfoRequestDecoder)
  44. end
  45. local function diceRequestEncoder(msg)
  46. local input = richHandler_pb.DiceRequest()
  47. protobuf.FromMessage(input,msg)
  48. return (input:SerializeToString())
  49. end
  50. local function diceRequestDecoder(stream)
  51. local res = richHandler_pb.DiceResponse()
  52. res:ParseFromString(stream)
  53. return res
  54. end
  55. function Pomelo.RichHandler.diceRequest(cb,option)
  56. local input = nil
  57. Socket.OnRequestStart("rich.richHandler.diceRequest", option)
  58. Socket.Request("rich.richHandler.diceRequest", input, function(res)
  59. if(res.s2c_code == 200) then
  60. Pomelo.RichHandler.lastDiceResponse = res
  61. Socket.OnRequestEnd("rich.richHandler.diceRequest", 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] rich.richHandler.diceRequest decode error!!"
  71. end
  72. Socket.OnRequestEnd("rich.richHandler.diceRequest", false,ex.Code,ex.Message)
  73. cb(ex,nil)
  74. end
  75. end, diceRequestEncoder, diceRequestDecoder)
  76. end
  77. local function fetchTurnAwardRequestEncoder(msg)
  78. local input = richHandler_pb.FetchTurnAwardRequest()
  79. protobuf.FromMessage(input,msg)
  80. return (input:SerializeToString())
  81. end
  82. local function fetchTurnAwardRequestDecoder(stream)
  83. local res = richHandler_pb.FetchTurnAwardResponse()
  84. res:ParseFromString(stream)
  85. return res
  86. end
  87. function Pomelo.RichHandler.fetchTurnAwardRequest(id,cb,option)
  88. local msg = {}
  89. msg.id = id
  90. Socket.OnRequestStart("rich.richHandler.fetchTurnAwardRequest", option)
  91. Socket.Request("rich.richHandler.fetchTurnAwardRequest", msg, function(res)
  92. if(res.s2c_code == 200) then
  93. Pomelo.RichHandler.lastFetchTurnAwardResponse = res
  94. Socket.OnRequestEnd("rich.richHandler.fetchTurnAwardRequest", true)
  95. cb(nil,res)
  96. else
  97. local ex = {}
  98. if(res.s2c_code) then
  99. ex.Code = res.s2c_code
  100. ex.Message = res.s2c_msg
  101. else
  102. ex.Code = 501
  103. ex.Message = "[LuaXmdsNetClient] rich.richHandler.fetchTurnAwardRequest decode error!!"
  104. end
  105. Socket.OnRequestEnd("rich.richHandler.fetchTurnAwardRequest", false,ex.Code,ex.Message)
  106. cb(ex,nil)
  107. end
  108. end, fetchTurnAwardRequestEncoder, fetchTurnAwardRequestDecoder)
  109. end
  110. --------------------------------Pomelo-------------------------------
  111. return Pomelo