SaleHandler.lua 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "saleHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------SaleHandler-------------------------------
  12. Pomelo.SaleHandler = {}
  13. local function buyPageRequestEncoder(msg)
  14. local input = saleHandler_pb.BuyPageRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function buyPageRequestDecoder(stream)
  19. local res = saleHandler_pb.BuyPageResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.SaleHandler.buyPageRequest(c2s_sellIndex,cb,option)
  24. local msg = {}
  25. msg.c2s_sellIndex = c2s_sellIndex
  26. Socket.OnRequestStart("area.saleHandler.buyPageRequest", option)
  27. Socket.Request("area.saleHandler.buyPageRequest", msg, function(res)
  28. if(res.s2c_code == 200) then
  29. Pomelo.SaleHandler.lastBuyPageResponse = res
  30. Socket.OnRequestEnd("area.saleHandler.buyPageRequest", true)
  31. cb(nil,res)
  32. else
  33. local ex = {}
  34. if(res.s2c_code) then
  35. ex.Code = res.s2c_code
  36. ex.Message = res.s2c_msg
  37. else
  38. ex.Code = 501
  39. ex.Message = "[LuaXmdsNetClient] area.saleHandler.buyPageRequest decode error!!"
  40. end
  41. Socket.OnRequestEnd("area.saleHandler.buyPageRequest", false,ex.Code,ex.Message)
  42. cb(ex,nil)
  43. end
  44. end, buyPageRequestEncoder, buyPageRequestDecoder)
  45. end
  46. local function buyItemRequestEncoder(msg)
  47. local input = saleHandler_pb.BuyItemRequest()
  48. protobuf.FromMessage(input,msg)
  49. return (input:SerializeToString())
  50. end
  51. local function buyItemRequestDecoder(stream)
  52. local res = saleHandler_pb.BuyItemResponse()
  53. res:ParseFromString(stream)
  54. return res
  55. end
  56. function Pomelo.SaleHandler.buyItemRequest(c2s_typeId,c2s_itemId,c2s_num,cb,option)
  57. local msg = {}
  58. msg.c2s_typeId = c2s_typeId
  59. msg.c2s_itemId = c2s_itemId
  60. msg.c2s_num = c2s_num
  61. Socket.OnRequestStart("area.saleHandler.buyItemRequest", option)
  62. Socket.Request("area.saleHandler.buyItemRequest", msg, function(res)
  63. if(res.s2c_code == 200) then
  64. Pomelo.SaleHandler.lastBuyItemResponse = res
  65. Socket.OnRequestEnd("area.saleHandler.buyItemRequest", true)
  66. cb(nil,res)
  67. else
  68. local ex = {}
  69. if(res.s2c_code) then
  70. ex.Code = res.s2c_code
  71. ex.Message = res.s2c_msg
  72. else
  73. ex.Code = 501
  74. ex.Message = "[LuaXmdsNetClient] area.saleHandler.buyItemRequest decode error!!"
  75. end
  76. Socket.OnRequestEnd("area.saleHandler.buyItemRequest", false,ex.Code,ex.Message)
  77. cb(ex,nil)
  78. end
  79. end, buyItemRequestEncoder, buyItemRequestDecoder)
  80. end
  81. local function autoBuyItemByCodeRequestEncoder(msg)
  82. local input = saleHandler_pb.AutoBuyItemByCodeRequest()
  83. protobuf.FromMessage(input,msg)
  84. return (input:SerializeToString())
  85. end
  86. local function autoBuyItemByCodeRequestDecoder(stream)
  87. local res = saleHandler_pb.AutoBuyItemByCodeResponse()
  88. res:ParseFromString(stream)
  89. return res
  90. end
  91. function Pomelo.SaleHandler.autoBuyItemByCodeRequest(c2s_typeId,c2s_itemCode,c2s_num,cb,option)
  92. local msg = {}
  93. msg.c2s_typeId = c2s_typeId
  94. msg.c2s_itemCode = c2s_itemCode
  95. msg.c2s_num = c2s_num
  96. Socket.OnRequestStart("area.saleHandler.autoBuyItemByCodeRequest", option)
  97. Socket.Request("area.saleHandler.autoBuyItemByCodeRequest", msg, function(res)
  98. if(res.s2c_code == 200) then
  99. Pomelo.SaleHandler.lastAutoBuyItemByCodeResponse = res
  100. Socket.OnRequestEnd("area.saleHandler.autoBuyItemByCodeRequest", 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] area.saleHandler.autoBuyItemByCodeRequest decode error!!"
  110. end
  111. Socket.OnRequestEnd("area.saleHandler.autoBuyItemByCodeRequest", false,ex.Code,ex.Message)
  112. cb(ex,nil)
  113. end
  114. end, autoBuyItemByCodeRequestEncoder, autoBuyItemByCodeRequestDecoder)
  115. end
  116. local function sellItemsRequestEncoder(msg)
  117. local input = saleHandler_pb.SellItemsRequest()
  118. protobuf.FromMessage(input,msg)
  119. return (input:SerializeToString())
  120. end
  121. local function sellItemsRequestDecoder(stream)
  122. local res = saleHandler_pb.SellItemsResponse()
  123. res:ParseFromString(stream)
  124. return res
  125. end
  126. function Pomelo.SaleHandler.sellItemsRequest(c2s_sellGrids,cb,option)
  127. local msg = {}
  128. msg.c2s_sellGrids = c2s_sellGrids
  129. Socket.OnRequestStart("area.saleHandler.sellItemsRequest", option)
  130. Socket.Request("area.saleHandler.sellItemsRequest", msg, function(res)
  131. if(res.s2c_code == 200) then
  132. Pomelo.SaleHandler.lastSellItemsResponse = res
  133. Socket.OnRequestEnd("area.saleHandler.sellItemsRequest", true)
  134. cb(nil,res)
  135. else
  136. local ex = {}
  137. if(res.s2c_code) then
  138. ex.Code = res.s2c_code
  139. ex.Message = res.s2c_msg
  140. else
  141. ex.Code = 501
  142. ex.Message = "[LuaXmdsNetClient] area.saleHandler.sellItemsRequest decode error!!"
  143. end
  144. Socket.OnRequestEnd("area.saleHandler.sellItemsRequest", false,ex.Code,ex.Message)
  145. cb(ex,nil)
  146. end
  147. end, sellItemsRequestEncoder, sellItemsRequestDecoder)
  148. end
  149. local function rebuyItemRequestEncoder(msg)
  150. local input = saleHandler_pb.RebuyItemRequest()
  151. protobuf.FromMessage(input,msg)
  152. return (input:SerializeToString())
  153. end
  154. local function rebuyItemRequestDecoder(stream)
  155. local res = saleHandler_pb.RebuyItemResponse()
  156. res:ParseFromString(stream)
  157. return res
  158. end
  159. function Pomelo.SaleHandler.rebuyItemRequest(c2s_gridIndex,c2s_num,cb,option)
  160. local msg = {}
  161. msg.c2s_gridIndex = c2s_gridIndex
  162. msg.c2s_num = c2s_num
  163. Socket.OnRequestStart("area.saleHandler.rebuyItemRequest", option)
  164. Socket.Request("area.saleHandler.rebuyItemRequest", msg, function(res)
  165. if(res.s2c_code == 200) then
  166. Pomelo.SaleHandler.lastRebuyItemResponse = res
  167. Socket.OnRequestEnd("area.saleHandler.rebuyItemRequest", true)
  168. cb(nil,res)
  169. else
  170. local ex = {}
  171. if(res.s2c_code) then
  172. ex.Code = res.s2c_code
  173. ex.Message = res.s2c_msg
  174. else
  175. ex.Code = 501
  176. ex.Message = "[LuaXmdsNetClient] area.saleHandler.rebuyItemRequest decode error!!"
  177. end
  178. Socket.OnRequestEnd("area.saleHandler.rebuyItemRequest", false,ex.Code,ex.Message)
  179. cb(ex,nil)
  180. end
  181. end, rebuyItemRequestEncoder, rebuyItemRequestDecoder)
  182. end
  183. --------------------------------Pomelo-------------------------------
  184. return Pomelo