RedPacketHandler.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "redPacketHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------RedPacketHandler-------------------------------
  12. Pomelo.RedPacketHandler = {}
  13. local function getRedPacketListRequestEncoder(msg)
  14. local input = redPacketHandler_pb.GetRedPacketListRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function getRedPacketListRequestDecoder(stream)
  19. local res = redPacketHandler_pb.GetRedPacketListResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.RedPacketHandler.getRedPacketListRequest(cb,option)
  24. local input = nil
  25. Socket.OnRequestStart("redpacket.redPacketHandler.getRedPacketListRequest", option)
  26. Socket.Request("redpacket.redPacketHandler.getRedPacketListRequest", input, function(res)
  27. if(res.s2c_code == 200) then
  28. Pomelo.RedPacketHandler.lastGetRedPacketListResponse = res
  29. Socket.OnRequestEnd("redpacket.redPacketHandler.getRedPacketListRequest", 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] redpacket.redPacketHandler.getRedPacketListRequest decode error!!"
  39. end
  40. Socket.OnRequestEnd("redpacket.redPacketHandler.getRedPacketListRequest", false,ex.Code,ex.Message)
  41. cb(ex,nil)
  42. end
  43. end, getRedPacketListRequestEncoder, getRedPacketListRequestDecoder)
  44. end
  45. local function dispatchRedPacketRequestEncoder(msg)
  46. local input = redPacketHandler_pb.DispatchRedPacketRequest()
  47. protobuf.FromMessage(input,msg)
  48. return (input:SerializeToString())
  49. end
  50. local function dispatchRedPacketRequestDecoder(stream)
  51. local res = redPacketHandler_pb.DispatchRedPacketResponse()
  52. res:ParseFromString(stream)
  53. return res
  54. end
  55. function Pomelo.RedPacketHandler.dispatchRedPacketRequest(count,totalNum,channelType,fetchType,benifitType,message,cb,option)
  56. local msg = {}
  57. msg.count = count
  58. msg.totalNum = totalNum
  59. msg.channelType = channelType
  60. msg.fetchType = fetchType
  61. msg.benifitType = benifitType
  62. msg.message = message
  63. Socket.OnRequestStart("redpacket.redPacketHandler.dispatchRedPacketRequest", option)
  64. Socket.Request("redpacket.redPacketHandler.dispatchRedPacketRequest", msg, function(res)
  65. if(res.s2c_code == 200) then
  66. Pomelo.RedPacketHandler.lastDispatchRedPacketResponse = res
  67. Socket.OnRequestEnd("redpacket.redPacketHandler.dispatchRedPacketRequest", true)
  68. cb(nil,res)
  69. else
  70. local ex = {}
  71. if(res.s2c_code) then
  72. ex.Code = res.s2c_code
  73. ex.Message = res.s2c_msg
  74. else
  75. ex.Code = 501
  76. ex.Message = "[LuaXmdsNetClient] redpacket.redPacketHandler.dispatchRedPacketRequest decode error!!"
  77. end
  78. Socket.OnRequestEnd("redpacket.redPacketHandler.dispatchRedPacketRequest", false,ex.Code,ex.Message)
  79. cb(ex,nil)
  80. end
  81. end, dispatchRedPacketRequestEncoder, dispatchRedPacketRequestDecoder)
  82. end
  83. local function fetchRedPacketRequestEncoder(msg)
  84. local input = redPacketHandler_pb.FetchRedPacketRequest()
  85. protobuf.FromMessage(input,msg)
  86. return (input:SerializeToString())
  87. end
  88. local function fetchRedPacketRequestDecoder(stream)
  89. local res = redPacketHandler_pb.FetchRedPacketResponse()
  90. res:ParseFromString(stream)
  91. return res
  92. end
  93. function Pomelo.RedPacketHandler.fetchRedPacketRequest(id,cb,option)
  94. local msg = {}
  95. msg.id = id
  96. Socket.OnRequestStart("redpacket.redPacketHandler.fetchRedPacketRequest", option)
  97. Socket.Request("redpacket.redPacketHandler.fetchRedPacketRequest", msg, function(res)
  98. if(res.s2c_code == 200) then
  99. Pomelo.RedPacketHandler.lastFetchRedPacketResponse = res
  100. Socket.OnRequestEnd("redpacket.redPacketHandler.fetchRedPacketRequest", true)
  101. cb(nil,res)
  102. else
  103. local ex = {}
  104. if(res.s2c_code) then
  105. ex.Code = res.s2c_code
  106. ex.Message = res.s2c_msg
  107. else
  108. ex.Code = 501
  109. ex.Message = "[LuaXmdsNetClient] redpacket.redPacketHandler.fetchRedPacketRequest decode error!!"
  110. end
  111. Socket.OnRequestEnd("redpacket.redPacketHandler.fetchRedPacketRequest", false,ex.Code,ex.Message)
  112. cb(ex,nil)
  113. end
  114. end, fetchRedPacketRequestEncoder, fetchRedPacketRequestDecoder)
  115. end
  116. local function onRedPacketDispatchPushDecoder(stream)
  117. local res = redPacketHandler_pb.OnRedPacketDispatchPush()
  118. res:ParseFromString(stream)
  119. return res
  120. end
  121. function Pomelo.RedPacketHandler.onRedPacketDispatchPush(cb)
  122. Socket.On("redpacket.redPacketPush.onRedPacketDispatchPush", function(res)
  123. Pomelo.RedPacketHandler.lastOnRedPacketDispatchPush = res
  124. cb(nil,res)
  125. end, onRedPacketDispatchPushDecoder)
  126. end
  127. --------------------------------Pomelo-------------------------------
  128. return Pomelo