ExchangeHandler.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "exchangeHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------ExchangeHandler-------------------------------
  12. Pomelo.ExchangeHandler = {}
  13. local function getExchangeLabelRequestEncoder(msg)
  14. local input = exchangeHandler_pb.GetExchangeLabelRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function getExchangeLabelRequestDecoder(stream)
  19. local res = exchangeHandler_pb.GetExchangeLabelResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.ExchangeHandler.getExchangeLabelRequest(c2s_npcId,cb,option)
  24. local msg = {}
  25. msg.c2s_npcId = c2s_npcId
  26. Socket.OnRequestStart("area.exchangeHandler.getExchangeLabelRequest", option)
  27. Socket.Request("area.exchangeHandler.getExchangeLabelRequest", msg, function(res)
  28. if(res.s2c_code == 200) then
  29. Pomelo.ExchangeHandler.lastGetExchangeLabelResponse = res
  30. Socket.OnRequestEnd("area.exchangeHandler.getExchangeLabelRequest", 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.exchangeHandler.getExchangeLabelRequest decode error!!"
  40. end
  41. Socket.OnRequestEnd("area.exchangeHandler.getExchangeLabelRequest", false,ex.Code,ex.Message)
  42. cb(ex,nil)
  43. end
  44. end, getExchangeLabelRequestEncoder, getExchangeLabelRequestDecoder)
  45. end
  46. local function getExchangeListRequestEncoder(msg)
  47. local input = exchangeHandler_pb.GetExchangeListRequest()
  48. protobuf.FromMessage(input,msg)
  49. return (input:SerializeToString())
  50. end
  51. local function getExchangeListRequestDecoder(stream)
  52. local res = exchangeHandler_pb.GetExchangeListResponse()
  53. res:ParseFromString(stream)
  54. return res
  55. end
  56. function Pomelo.ExchangeHandler.getExchangeListRequest(c2s_npcId,c2s_typeId,cb,option)
  57. local msg = {}
  58. msg.c2s_npcId = c2s_npcId
  59. msg.c2s_typeId = c2s_typeId
  60. Socket.OnRequestStart("area.exchangeHandler.getExchangeListRequest", option)
  61. Socket.Request("area.exchangeHandler.getExchangeListRequest", msg, function(res)
  62. if(res.s2c_code == 200) then
  63. Pomelo.ExchangeHandler.lastGetExchangeListResponse = res
  64. Socket.OnRequestEnd("area.exchangeHandler.getExchangeListRequest", 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.exchangeHandler.getExchangeListRequest decode error!!"
  74. end
  75. Socket.OnRequestEnd("area.exchangeHandler.getExchangeListRequest", false,ex.Code,ex.Message)
  76. cb(ex,nil)
  77. end
  78. end, getExchangeListRequestEncoder, getExchangeListRequestDecoder)
  79. end
  80. local function exchangeItemRequestEncoder(msg)
  81. local input = exchangeHandler_pb.ExchangeItemRequest()
  82. protobuf.FromMessage(input,msg)
  83. return (input:SerializeToString())
  84. end
  85. local function exchangeItemRequestDecoder(stream)
  86. local res = exchangeHandler_pb.ExchangeItemResponse()
  87. res:ParseFromString(stream)
  88. return res
  89. end
  90. function Pomelo.ExchangeHandler.exchangeItemRequest(c2s_typeId,c2s_itemId,c2s_num,c2s_npcId,cb,option)
  91. local msg = {}
  92. msg.c2s_typeId = c2s_typeId
  93. msg.c2s_itemId = c2s_itemId
  94. msg.c2s_num = c2s_num
  95. msg.c2s_npcId = c2s_npcId
  96. Socket.OnRequestStart("area.exchangeHandler.exchangeItemRequest", option)
  97. Socket.Request("area.exchangeHandler.exchangeItemRequest", msg, function(res)
  98. if(res.s2c_code == 200) then
  99. Pomelo.ExchangeHandler.lastExchangeItemResponse = res
  100. Socket.OnRequestEnd("area.exchangeHandler.exchangeItemRequest", 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.exchangeHandler.exchangeItemRequest decode error!!"
  110. end
  111. Socket.OnRequestEnd("area.exchangeHandler.exchangeItemRequest", false,ex.Code,ex.Message)
  112. cb(ex,nil)
  113. end
  114. end, exchangeItemRequestEncoder, exchangeItemRequestDecoder)
  115. end
  116. local function allyFightExchangeRequestEncoder(msg)
  117. local input = exchangeHandler_pb.AllyFightExchangeRequest()
  118. protobuf.FromMessage(input,msg)
  119. return (input:SerializeToString())
  120. end
  121. local function allyFightExchangeRequestDecoder(stream)
  122. local res = exchangeHandler_pb.AllyFightExchangeResponse()
  123. res:ParseFromString(stream)
  124. return res
  125. end
  126. function Pomelo.ExchangeHandler.allyFightExchangeRequest(c2s_npcId,c2s_typeId,cb,option)
  127. local msg = {}
  128. msg.c2s_npcId = c2s_npcId
  129. msg.c2s_typeId = c2s_typeId
  130. Socket.OnRequestStart("area.exchangeHandler.allyFightExchangeRequest", option)
  131. Socket.Request("area.exchangeHandler.allyFightExchangeRequest", msg, function(res)
  132. if(res.s2c_code == 200) then
  133. Pomelo.ExchangeHandler.lastAllyFightExchangeResponse = res
  134. Socket.OnRequestEnd("area.exchangeHandler.allyFightExchangeRequest", 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.exchangeHandler.allyFightExchangeRequest decode error!!"
  144. end
  145. Socket.OnRequestEnd("area.exchangeHandler.allyFightExchangeRequest", false,ex.Code,ex.Message)
  146. cb(ex,nil)
  147. end
  148. end, allyFightExchangeRequestEncoder, allyFightExchangeRequestDecoder)
  149. end
  150. --------------------------------Pomelo-------------------------------
  151. return Pomelo