ChatHandler.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "chatHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------ChatHandler-------------------------------
  12. Pomelo.ChatHandler = {}
  13. local function sendChatRequestEncoder(msg)
  14. local input = chatHandler_pb.SendChatRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function sendChatRequestDecoder(stream)
  19. local res = chatHandler_pb.SendChatResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.ChatHandler.sendChatRequest(c2s_scope,c2s_content,c2s_acceptRoleId,cb,option)
  24. local msg = {}
  25. msg.c2s_scope = c2s_scope
  26. msg.c2s_content = c2s_content
  27. msg.c2s_acceptRoleId = c2s_acceptRoleId
  28. Socket.OnRequestStart("chat.chatHandler.sendChatRequest", option)
  29. Socket.Request("chat.chatHandler.sendChatRequest", msg, function(res)
  30. if(res.s2c_code == 200) then
  31. Pomelo.ChatHandler.lastSendChatResponse = res
  32. Socket.OnRequestEnd("chat.chatHandler.sendChatRequest", true)
  33. cb(nil,res)
  34. else
  35. local ex = {}
  36. if(res.s2c_code) then
  37. ex.Code = res.s2c_code
  38. ex.Message = res.s2c_msg
  39. else
  40. ex.Code = 501
  41. ex.Message = "[LuaXmdsNetClient] chat.chatHandler.sendChatRequest decode error!!"
  42. end
  43. Socket.OnRequestEnd("chat.chatHandler.sendChatRequest", false,ex.Code,ex.Message)
  44. cb(ex,nil)
  45. end
  46. end, sendChatRequestEncoder, sendChatRequestDecoder)
  47. end
  48. local function getSaveChatMsgRequestEncoder(msg)
  49. local input = chatHandler_pb.GetSaveChatMsgRequest()
  50. protobuf.FromMessage(input,msg)
  51. return (input:SerializeToString())
  52. end
  53. local function getSaveChatMsgRequestDecoder(stream)
  54. local res = chatHandler_pb.GetSaveChatMsgResponse()
  55. res:ParseFromString(stream)
  56. return res
  57. end
  58. function Pomelo.ChatHandler.getSaveChatMsgRequest(c2s_scope,c2s_index,c2s_uid,cb,option)
  59. local msg = {}
  60. msg.c2s_scope = c2s_scope
  61. msg.c2s_index = c2s_index
  62. msg.c2s_uid = c2s_uid
  63. Socket.OnRequestStart("chat.chatHandler.getSaveChatMsgRequest", option)
  64. Socket.Request("chat.chatHandler.getSaveChatMsgRequest", msg, function(res)
  65. if(res.s2c_code == 200) then
  66. Pomelo.ChatHandler.lastGetSaveChatMsgResponse = res
  67. Socket.OnRequestEnd("chat.chatHandler.getSaveChatMsgRequest", 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] chat.chatHandler.getSaveChatMsgRequest decode error!!"
  77. end
  78. Socket.OnRequestEnd("chat.chatHandler.getSaveChatMsgRequest", false,ex.Code,ex.Message)
  79. cb(ex,nil)
  80. end
  81. end, getSaveChatMsgRequestEncoder, getSaveChatMsgRequestDecoder)
  82. end
  83. local function crossChatSwitchButtonRequestEncoder(msg)
  84. local input = chatHandler_pb.CrossChatSwitchButtonRequest()
  85. protobuf.FromMessage(input,msg)
  86. return (input:SerializeToString())
  87. end
  88. local function crossChatSwitchButtonRequestDecoder(stream)
  89. local res = chatHandler_pb.CrossChatSwitchButtonResponse()
  90. res:ParseFromString(stream)
  91. return res
  92. end
  93. function Pomelo.ChatHandler.crossChatSwitchButtonRequest(isAllServerChat,optype,cb,option)
  94. local msg = {}
  95. msg.isAllServerChat = isAllServerChat
  96. msg.optype = optype
  97. Socket.OnRequestStart("chat.chatHandler.crossChatSwitchButtonRequest", option)
  98. Socket.Request("chat.chatHandler.crossChatSwitchButtonRequest", msg, function(res)
  99. if(res.s2c_code == 200) then
  100. Pomelo.ChatHandler.lastCrossChatSwitchButtonResponse = res
  101. Socket.OnRequestEnd("chat.chatHandler.crossChatSwitchButtonRequest", true)
  102. cb(nil,res)
  103. else
  104. local ex = {}
  105. if(res.s2c_code) then
  106. ex.Code = res.s2c_code
  107. ex.Message = res.s2c_msg
  108. else
  109. ex.Code = 501
  110. ex.Message = "[LuaXmdsNetClient] chat.chatHandler.crossChatSwitchButtonRequest decode error!!"
  111. end
  112. Socket.OnRequestEnd("chat.chatHandler.crossChatSwitchButtonRequest", false,ex.Code,ex.Message)
  113. cb(ex,nil)
  114. end
  115. end, crossChatSwitchButtonRequestEncoder, crossChatSwitchButtonRequestDecoder)
  116. end
  117. local function onChatPushDecoder(stream)
  118. local res = chatHandler_pb.OnChatPush()
  119. res:ParseFromString(stream)
  120. return res
  121. end
  122. function Pomelo.ChatHandler.onChatPush(cb)
  123. Socket.On("chat.chatPush.onChatPush", function(res)
  124. Pomelo.ChatHandler.lastOnChatPush = res
  125. cb(nil,res)
  126. end, onChatPushDecoder)
  127. end
  128. local function onChatErrorPushDecoder(stream)
  129. local res = chatHandler_pb.OnChatErrorPush()
  130. res:ParseFromString(stream)
  131. return res
  132. end
  133. function Pomelo.ChatHandler.onChatErrorPush(cb)
  134. Socket.On("chat.chatPush.onChatErrorPush", function(res)
  135. Pomelo.ChatHandler.lastOnChatErrorPush = res
  136. cb(nil,res)
  137. end, onChatErrorPushDecoder)
  138. end
  139. local function tipPushDecoder(stream)
  140. local res = chatHandler_pb.TipPush()
  141. res:ParseFromString(stream)
  142. return res
  143. end
  144. function Pomelo.ChatHandler.tipPush(cb)
  145. Socket.On("chat.chatPush.tipPush", function(res)
  146. Pomelo.ChatHandler.lastTipPush = res
  147. cb(nil,res)
  148. end, tipPushDecoder)
  149. end
  150. --------------------------------Pomelo-------------------------------
  151. return Pomelo