MailHandler.lua 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "mailHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------MailHandler-------------------------------
  12. Pomelo.MailHandler = {}
  13. local function mailGetAllRequestEncoder(msg)
  14. local input = mailHandler_pb.MailGetAllRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function mailGetAllRequestDecoder(stream)
  19. local res = mailHandler_pb.MailGetAllResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.MailHandler.mailGetAllRequest(cb,option)
  24. local input = nil
  25. Socket.OnRequestStart("area.mailHandler.mailGetAllRequest", option)
  26. Socket.Request("area.mailHandler.mailGetAllRequest", input, function(res)
  27. if(res.s2c_code == 200) then
  28. Pomelo.MailHandler.lastMailGetAllResponse = res
  29. Socket.OnRequestEnd("area.mailHandler.mailGetAllRequest", 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] area.mailHandler.mailGetAllRequest decode error!!"
  39. end
  40. Socket.OnRequestEnd("area.mailHandler.mailGetAllRequest", false,ex.Code,ex.Message)
  41. cb(ex,nil)
  42. end
  43. end, mailGetAllRequestEncoder, mailGetAllRequestDecoder)
  44. end
  45. local function mailSendMailRequestEncoder(msg)
  46. local input = mailHandler_pb.MailSendMailRequest()
  47. protobuf.FromMessage(input,msg)
  48. return (input:SerializeToString())
  49. end
  50. local function mailSendMailRequestDecoder(stream)
  51. local res = mailHandler_pb.MailSendMailResponse()
  52. res:ParseFromString(stream)
  53. return res
  54. end
  55. function Pomelo.MailHandler.mailSendMailRequest(toPlayerId,mailTitle,mailText,mailRead,toPlayerName,cb,option)
  56. local msg = {}
  57. msg.toPlayerId = toPlayerId
  58. msg.mailTitle = mailTitle
  59. msg.mailText = mailText
  60. msg.mailRead = mailRead
  61. msg.toPlayerName = toPlayerName
  62. Socket.OnRequestStart("area.mailHandler.mailSendMailRequest", option)
  63. Socket.Request("area.mailHandler.mailSendMailRequest", msg, function(res)
  64. if(res.s2c_code == 200) then
  65. Pomelo.MailHandler.lastMailSendMailResponse = res
  66. Socket.OnRequestEnd("area.mailHandler.mailSendMailRequest", true)
  67. cb(nil,res)
  68. else
  69. local ex = {}
  70. if(res.s2c_code) then
  71. ex.Code = res.s2c_code
  72. ex.Message = res.s2c_msg
  73. else
  74. ex.Code = 501
  75. ex.Message = "[LuaXmdsNetClient] area.mailHandler.mailSendMailRequest decode error!!"
  76. end
  77. Socket.OnRequestEnd("area.mailHandler.mailSendMailRequest", false,ex.Code,ex.Message)
  78. cb(ex,nil)
  79. end
  80. end, mailSendMailRequestEncoder, mailSendMailRequestDecoder)
  81. end
  82. local function mailDeleteRequestEncoder(msg)
  83. local input = mailHandler_pb.MailDeleteRequest()
  84. protobuf.FromMessage(input,msg)
  85. return (input:SerializeToString())
  86. end
  87. local function mailDeleteRequestDecoder(stream)
  88. local res = mailHandler_pb.MailDeleteResponse()
  89. res:ParseFromString(stream)
  90. return res
  91. end
  92. function Pomelo.MailHandler.mailDeleteRequest(c2s_id,cb,option)
  93. local msg = {}
  94. msg.c2s_id = c2s_id
  95. Socket.OnRequestStart("area.mailHandler.mailDeleteRequest", option)
  96. Socket.Request("area.mailHandler.mailDeleteRequest", msg, function(res)
  97. if(res.s2c_code == 200) then
  98. Pomelo.MailHandler.lastMailDeleteResponse = res
  99. Socket.OnRequestEnd("area.mailHandler.mailDeleteRequest", true)
  100. cb(nil,res)
  101. else
  102. local ex = {}
  103. if(res.s2c_code) then
  104. ex.Code = res.s2c_code
  105. ex.Message = res.s2c_msg
  106. else
  107. ex.Code = 501
  108. ex.Message = "[LuaXmdsNetClient] area.mailHandler.mailDeleteRequest decode error!!"
  109. end
  110. Socket.OnRequestEnd("area.mailHandler.mailDeleteRequest", false,ex.Code,ex.Message)
  111. cb(ex,nil)
  112. end
  113. end, mailDeleteRequestEncoder, mailDeleteRequestDecoder)
  114. end
  115. local function mailDeleteOneKeyRequestEncoder(msg)
  116. local input = mailHandler_pb.MailDeleteOneKeyRequest()
  117. protobuf.FromMessage(input,msg)
  118. return (input:SerializeToString())
  119. end
  120. local function mailDeleteOneKeyRequestDecoder(stream)
  121. local res = mailHandler_pb.MailDeleteOneKeyResponse()
  122. res:ParseFromString(stream)
  123. return res
  124. end
  125. function Pomelo.MailHandler.mailDeleteOneKeyRequest(cb,option)
  126. local input = nil
  127. Socket.OnRequestStart("area.mailHandler.mailDeleteOneKeyRequest", option)
  128. Socket.Request("area.mailHandler.mailDeleteOneKeyRequest", input, function(res)
  129. if(res.s2c_code == 200) then
  130. Pomelo.MailHandler.lastMailDeleteOneKeyResponse = res
  131. Socket.OnRequestEnd("area.mailHandler.mailDeleteOneKeyRequest", true)
  132. cb(nil,res)
  133. else
  134. local ex = {}
  135. if(res.s2c_code) then
  136. ex.Code = res.s2c_code
  137. ex.Message = res.s2c_msg
  138. else
  139. ex.Code = 501
  140. ex.Message = "[LuaXmdsNetClient] area.mailHandler.mailDeleteOneKeyRequest decode error!!"
  141. end
  142. Socket.OnRequestEnd("area.mailHandler.mailDeleteOneKeyRequest", false,ex.Code,ex.Message)
  143. cb(ex,nil)
  144. end
  145. end, mailDeleteOneKeyRequestEncoder, mailDeleteOneKeyRequestDecoder)
  146. end
  147. local function mailGetAttachmentRequestEncoder(msg)
  148. local input = mailHandler_pb.MailGetAttachmentRequest()
  149. protobuf.FromMessage(input,msg)
  150. return (input:SerializeToString())
  151. end
  152. local function mailGetAttachmentRequestDecoder(stream)
  153. local res = mailHandler_pb.MailGetAttachmentResponse()
  154. res:ParseFromString(stream)
  155. return res
  156. end
  157. function Pomelo.MailHandler.mailGetAttachmentRequest(c2s_id,cb,option)
  158. local msg = {}
  159. msg.c2s_id = c2s_id
  160. Socket.OnRequestStart("area.mailHandler.mailGetAttachmentRequest", option)
  161. Socket.Request("area.mailHandler.mailGetAttachmentRequest", msg, function(res)
  162. if(res.s2c_code == 200) then
  163. Pomelo.MailHandler.lastMailGetAttachmentResponse = res
  164. Socket.OnRequestEnd("area.mailHandler.mailGetAttachmentRequest", true)
  165. cb(nil,res)
  166. else
  167. local ex = {}
  168. if(res.s2c_code) then
  169. ex.Code = res.s2c_code
  170. ex.Message = res.s2c_msg
  171. else
  172. ex.Code = 501
  173. ex.Message = "[LuaXmdsNetClient] area.mailHandler.mailGetAttachmentRequest decode error!!"
  174. end
  175. Socket.OnRequestEnd("area.mailHandler.mailGetAttachmentRequest", false,ex.Code,ex.Message)
  176. cb(ex,nil)
  177. end
  178. end, mailGetAttachmentRequestEncoder, mailGetAttachmentRequestDecoder)
  179. end
  180. local function mailGetAttachmentOneKeyRequestEncoder(msg)
  181. local input = mailHandler_pb.MailGetAttachmentOneKeyRequest()
  182. protobuf.FromMessage(input,msg)
  183. return (input:SerializeToString())
  184. end
  185. local function mailGetAttachmentOneKeyRequestDecoder(stream)
  186. local res = mailHandler_pb.MailGetAttachmentOneKeyResponse()
  187. res:ParseFromString(stream)
  188. return res
  189. end
  190. function Pomelo.MailHandler.mailGetAttachmentOneKeyRequest(cb,option)
  191. local input = nil
  192. Socket.OnRequestStart("area.mailHandler.mailGetAttachmentOneKeyRequest", option)
  193. Socket.Request("area.mailHandler.mailGetAttachmentOneKeyRequest", input, function(res)
  194. if(res.s2c_code == 200) then
  195. Pomelo.MailHandler.lastMailGetAttachmentOneKeyResponse = res
  196. Socket.OnRequestEnd("area.mailHandler.mailGetAttachmentOneKeyRequest", true)
  197. cb(nil,res)
  198. else
  199. local ex = {}
  200. if(res.s2c_code) then
  201. ex.Code = res.s2c_code
  202. ex.Message = res.s2c_msg
  203. else
  204. ex.Code = 501
  205. ex.Message = "[LuaXmdsNetClient] area.mailHandler.mailGetAttachmentOneKeyRequest decode error!!"
  206. end
  207. Socket.OnRequestEnd("area.mailHandler.mailGetAttachmentOneKeyRequest", false,ex.Code,ex.Message)
  208. cb(ex,nil)
  209. end
  210. end, mailGetAttachmentOneKeyRequestEncoder, mailGetAttachmentOneKeyRequestDecoder)
  211. end
  212. local function mailReadNotifyEncoder(msg)
  213. local input = mailHandler_pb.MailReadNotify()
  214. protobuf.FromMessage(input,msg)
  215. return (input:SerializeToString())
  216. end
  217. function Pomelo.MailHandler.mailReadNotify(c2s_id)
  218. local msg = {}
  219. msg.c2s_id = c2s_id
  220. Socket.Notify("area.mailHandler.mailReadNotify", msg, mailReadNotifyEncoder)
  221. end
  222. local function mailSendTestNotifyEncoder(msg)
  223. local input = mailHandler_pb.MailSendTestNotify()
  224. protobuf.FromMessage(input,msg)
  225. return (input:SerializeToString())
  226. end
  227. function Pomelo.MailHandler.mailSendTestNotify(c2s_mailId,c2s_tcCode)
  228. local msg = {}
  229. msg.c2s_mailId = c2s_mailId
  230. msg.c2s_tcCode = c2s_tcCode
  231. Socket.Notify("area.mailHandler.mailSendTestNotify", msg, mailSendTestNotifyEncoder)
  232. end
  233. local function onGetMailPushDecoder(stream)
  234. local res = mailHandler_pb.OnGetMailPush()
  235. res:ParseFromString(stream)
  236. return res
  237. end
  238. function Pomelo.MailHandler.onGetMailPush(cb)
  239. Socket.On("area.mailPush.onGetMailPush", function(res)
  240. Pomelo.MailHandler.lastOnGetMailPush = res
  241. cb(nil,res)
  242. end, onGetMailPushDecoder)
  243. end
  244. --------------------------------Pomelo-------------------------------
  245. return Pomelo