BagHandler.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "bagHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------BagHandler-------------------------------
  12. Pomelo.BagHandler = {}
  13. local function packUpBagRequestEncoder(msg)
  14. local input = bagHandler_pb.PackUpBagRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function packUpBagRequestDecoder(stream)
  19. local res = bagHandler_pb.PackUpBagResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.BagHandler.packUpBagRequest(c2s_type,cb,option)
  24. local msg = {}
  25. msg.c2s_type = c2s_type
  26. Socket.OnRequestStart("area.bagHandler.packUpBagRequest", option)
  27. Socket.Request("area.bagHandler.packUpBagRequest", msg, function(res)
  28. if(res.s2c_code == 200) then
  29. Pomelo.BagHandler.lastPackUpBagResponse = res
  30. Socket.OnRequestEnd("area.bagHandler.packUpBagRequest", 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.bagHandler.packUpBagRequest decode error!!"
  40. end
  41. Socket.OnRequestEnd("area.bagHandler.packUpBagRequest", false,ex.Code,ex.Message)
  42. cb(ex,nil)
  43. end
  44. end, packUpBagRequestEncoder, packUpBagRequestDecoder)
  45. end
  46. local function openBagGridRequestEncoder(msg)
  47. local input = bagHandler_pb.OpenBagGridRequest()
  48. protobuf.FromMessage(input,msg)
  49. return (input:SerializeToString())
  50. end
  51. local function openBagGridRequestDecoder(stream)
  52. local res = bagHandler_pb.OpenBagGridResponse()
  53. res:ParseFromString(stream)
  54. return res
  55. end
  56. function Pomelo.BagHandler.openBagGridRequest(c2s_type,c2s_number,cb,option)
  57. local msg = {}
  58. msg.c2s_type = c2s_type
  59. msg.c2s_number = c2s_number
  60. Socket.OnRequestStart("area.bagHandler.openBagGridRequest", option)
  61. Socket.Request("area.bagHandler.openBagGridRequest", msg, function(res)
  62. if(res.s2c_code == 200) then
  63. Pomelo.BagHandler.lastOpenBagGridResponse = res
  64. Socket.OnRequestEnd("area.bagHandler.openBagGridRequest", true)
  65. cb(nil,res)
  66. else
  67. local ex = {}
  68. if(res.s2c_code) then
  69. ex.Code = res.s2c_code
  70. ex.Message = res.s2c_msg
  71. else
  72. ex.Code = 501
  73. ex.Message = "[LuaXmdsNetClient] area.bagHandler.openBagGridRequest decode error!!"
  74. end
  75. Socket.OnRequestEnd("area.bagHandler.openBagGridRequest", false,ex.Code,ex.Message)
  76. cb(ex,nil)
  77. end
  78. end, openBagGridRequestEncoder, openBagGridRequestDecoder)
  79. end
  80. local function transferItemRequestEncoder(msg)
  81. local input = bagHandler_pb.TransferItemRequest()
  82. protobuf.FromMessage(input,msg)
  83. return (input:SerializeToString())
  84. end
  85. local function transferItemRequestDecoder(stream)
  86. local res = bagHandler_pb.TransferItemResponse()
  87. res:ParseFromString(stream)
  88. return res
  89. end
  90. function Pomelo.BagHandler.transferItemRequest(c2s_fromType,c2s_fromIndex,c2s_toType,c2s_num,cb,option)
  91. local msg = {}
  92. msg.c2s_fromType = c2s_fromType
  93. msg.c2s_fromIndex = c2s_fromIndex
  94. msg.c2s_toType = c2s_toType
  95. msg.c2s_num = c2s_num
  96. Socket.OnRequestStart("area.bagHandler.transferItemRequest", option)
  97. Socket.Request("area.bagHandler.transferItemRequest", msg, function(res)
  98. if(res.s2c_code == 200) then
  99. Pomelo.BagHandler.lastTransferItemResponse = res
  100. Socket.OnRequestEnd("area.bagHandler.transferItemRequest", 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.bagHandler.transferItemRequest decode error!!"
  110. end
  111. Socket.OnRequestEnd("area.bagHandler.transferItemRequest", false,ex.Code,ex.Message)
  112. cb(ex,nil)
  113. end
  114. end, transferItemRequestEncoder, transferItemRequestDecoder)
  115. end
  116. local function sellItemRequestEncoder(msg)
  117. local input = bagHandler_pb.SellItemRequest()
  118. protobuf.FromMessage(input,msg)
  119. return (input:SerializeToString())
  120. end
  121. local function sellItemRequestDecoder(stream)
  122. local res = bagHandler_pb.SellItemResponse()
  123. res:ParseFromString(stream)
  124. return res
  125. end
  126. function Pomelo.BagHandler.sellItemRequest(c2s_gridIndex,c2s_num,cb,option)
  127. local msg = {}
  128. msg.c2s_gridIndex = c2s_gridIndex
  129. msg.c2s_num = c2s_num
  130. Socket.OnRequestStart("area.bagHandler.sellItemRequest", option)
  131. Socket.Request("area.bagHandler.sellItemRequest", msg, function(res)
  132. if(res.s2c_code == 200) then
  133. Pomelo.BagHandler.lastSellItemResponse = res
  134. Socket.OnRequestEnd("area.bagHandler.sellItemRequest", true)
  135. cb(nil,res)
  136. else
  137. local ex = {}
  138. if(res.s2c_code) then
  139. ex.Code = res.s2c_code
  140. ex.Message = res.s2c_msg
  141. else
  142. ex.Code = 501
  143. ex.Message = "[LuaXmdsNetClient] area.bagHandler.sellItemRequest decode error!!"
  144. end
  145. Socket.OnRequestEnd("area.bagHandler.sellItemRequest", false,ex.Code,ex.Message)
  146. cb(ex,nil)
  147. end
  148. end, sellItemRequestEncoder, sellItemRequestDecoder)
  149. end
  150. local function sellItemBatchRequestEncoder(msg)
  151. local input = bagHandler_pb.SellItemBatchRequest()
  152. protobuf.FromMessage(input,msg)
  153. return (input:SerializeToString())
  154. end
  155. local function sellItemBatchRequestDecoder(stream)
  156. local res = bagHandler_pb.SellItemBatchResponse()
  157. res:ParseFromString(stream)
  158. return res
  159. end
  160. function Pomelo.BagHandler.sellItemBatchRequest(c2s_gridList,cb,option)
  161. local msg = {}
  162. msg.c2s_gridList = c2s_gridList
  163. Socket.OnRequestStart("area.bagHandler.sellItemBatchRequest", option)
  164. Socket.Request("area.bagHandler.sellItemBatchRequest", msg, function(res)
  165. if(res.s2c_code == 200) then
  166. Pomelo.BagHandler.lastSellItemBatchResponse = res
  167. Socket.OnRequestEnd("area.bagHandler.sellItemBatchRequest", 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.bagHandler.sellItemBatchRequest decode error!!"
  177. end
  178. Socket.OnRequestEnd("area.bagHandler.sellItemBatchRequest", false,ex.Code,ex.Message)
  179. cb(ex,nil)
  180. end
  181. end, sellItemBatchRequestEncoder, sellItemBatchRequestDecoder)
  182. end
  183. local function useItemRequestEncoder(msg)
  184. local input = bagHandler_pb.UseItemRequest()
  185. protobuf.FromMessage(input,msg)
  186. return (input:SerializeToString())
  187. end
  188. local function useItemRequestDecoder(stream)
  189. local res = bagHandler_pb.UseItemResponse()
  190. res:ParseFromString(stream)
  191. return res
  192. end
  193. function Pomelo.BagHandler.useItemRequest(c2s_gridIndex,c2s_num,cb,option)
  194. local msg = {}
  195. msg.c2s_gridIndex = c2s_gridIndex
  196. msg.c2s_num = c2s_num
  197. Socket.OnRequestStart("area.bagHandler.useItemRequest", option)
  198. Socket.Request("area.bagHandler.useItemRequest", msg, function(res)
  199. if(res.s2c_code == 200) then
  200. Pomelo.BagHandler.lastUseItemResponse = res
  201. Socket.OnRequestEnd("area.bagHandler.useItemRequest", true)
  202. cb(nil,res)
  203. else
  204. local ex = {}
  205. if(res.s2c_code) then
  206. ex.Code = res.s2c_code
  207. ex.Message = res.s2c_msg
  208. else
  209. ex.Code = 501
  210. ex.Message = "[LuaXmdsNetClient] area.bagHandler.useItemRequest decode error!!"
  211. end
  212. Socket.OnRequestEnd("area.bagHandler.useItemRequest", false,ex.Code,ex.Message)
  213. cb(ex,nil)
  214. end
  215. end, useItemRequestEncoder, useItemRequestDecoder)
  216. end
  217. local function disintegrationRequestEncoder(msg)
  218. local input = bagHandler_pb.DisintegrationRequest()
  219. protobuf.FromMessage(input,msg)
  220. return (input:SerializeToString())
  221. end
  222. local function disintegrationRequestDecoder(stream)
  223. local res = bagHandler_pb.DisintegrationResponse()
  224. res:ParseFromString(stream)
  225. return res
  226. end
  227. function Pomelo.BagHandler.disintegrationRequest(c2s_gridIndex,c2s_num,cb,option)
  228. local msg = {}
  229. msg.c2s_gridIndex = c2s_gridIndex
  230. msg.c2s_num = c2s_num
  231. Socket.OnRequestStart("area.bagHandler.disintegrationRequest", option)
  232. Socket.Request("area.bagHandler.disintegrationRequest", msg, function(res)
  233. if(res.s2c_code == 200) then
  234. Pomelo.BagHandler.lastDisintegrationResponse = res
  235. Socket.OnRequestEnd("area.bagHandler.disintegrationRequest", true)
  236. cb(nil,res)
  237. else
  238. local ex = {}
  239. if(res.s2c_code) then
  240. ex.Code = res.s2c_code
  241. ex.Message = res.s2c_msg
  242. else
  243. ex.Code = 501
  244. ex.Message = "[LuaXmdsNetClient] area.bagHandler.disintegrationRequest decode error!!"
  245. end
  246. Socket.OnRequestEnd("area.bagHandler.disintegrationRequest", false,ex.Code,ex.Message)
  247. cb(ex,nil)
  248. end
  249. end, disintegrationRequestEncoder, disintegrationRequestDecoder)
  250. end
  251. local function addBagItemTestNotifyEncoder(msg)
  252. local input = bagHandler_pb.AddBagItemTestNotify()
  253. protobuf.FromMessage(input,msg)
  254. return (input:SerializeToString())
  255. end
  256. function Pomelo.BagHandler.addBagItemTestNotify()
  257. local msg = nil
  258. Socket.Notify("area.bagHandler.addBagItemTestNotify", msg, addBagItemTestNotifyEncoder)
  259. end
  260. local function bagItemUpdatePushDecoder(stream)
  261. local res = bagHandler_pb.BagItemUpdatePush()
  262. res:ParseFromString(stream)
  263. return res
  264. end
  265. function Pomelo.BagHandler.bagItemUpdatePush(cb)
  266. Socket.On("area.bagPush.bagItemUpdatePush", function(res)
  267. Pomelo.BagHandler.lastBagItemUpdatePush = res
  268. cb(nil,res)
  269. end, bagItemUpdatePushDecoder)
  270. end
  271. local function bagNewItemPushDecoder(stream)
  272. local res = bagHandler_pb.BagNewItemPush()
  273. res:ParseFromString(stream)
  274. return res
  275. end
  276. function Pomelo.BagHandler.bagNewItemPush(cb)
  277. Socket.On("area.bagPush.bagNewItemPush", function(res)
  278. Pomelo.BagHandler.lastBagNewItemPush = res
  279. cb(nil,res)
  280. end, bagNewItemPushDecoder)
  281. end
  282. local function bagNewEquipPushDecoder(stream)
  283. local res = bagHandler_pb.BagNewEquipPush()
  284. res:ParseFromString(stream)
  285. return res
  286. end
  287. function Pomelo.BagHandler.bagNewEquipPush(cb)
  288. Socket.On("area.bagPush.bagNewEquipPush", function(res)
  289. Pomelo.BagHandler.lastBagNewEquipPush = res
  290. cb(nil,res)
  291. end, bagNewEquipPushDecoder)
  292. end
  293. local function bagGridFullPushDecoder(stream)
  294. local res = bagHandler_pb.BagGridFullPush()
  295. res:ParseFromString(stream)
  296. return res
  297. end
  298. function Pomelo.BagHandler.bagGridFullPush(cb)
  299. Socket.On("area.bagPush.bagGridFullPush", function(res)
  300. Pomelo.BagHandler.lastBagGridFullPush = res
  301. cb(nil,res)
  302. end, bagGridFullPushDecoder)
  303. end
  304. local function bagGridNumPushDecoder(stream)
  305. local res = bagHandler_pb.BagGridNumPush()
  306. res:ParseFromString(stream)
  307. return res
  308. end
  309. function Pomelo.BagHandler.bagGridNumPush(cb)
  310. Socket.On("area.bagPush.bagGridNumPush", function(res)
  311. Pomelo.BagHandler.lastBagGridNumPush = res
  312. cb(nil,res)
  313. end, bagGridNumPushDecoder)
  314. end
  315. local function bagNewItemFromResFubenPushDecoder(stream)
  316. local res = bagHandler_pb.BagNewItemFromResFubenPush()
  317. res:ParseFromString(stream)
  318. return res
  319. end
  320. function Pomelo.BagHandler.bagNewItemFromResFubenPush(cb)
  321. Socket.On("area.bagPush.bagNewItemFromResFubenPush", function(res)
  322. Pomelo.BagHandler.lastBagNewItemFromResFubenPush = res
  323. cb(nil,res)
  324. end, bagNewItemFromResFubenPushDecoder)
  325. end
  326. --------------------------------Pomelo-------------------------------
  327. return Pomelo