RoleHandler.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "roleHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------RoleHandler-------------------------------
  12. Pomelo.RoleHandler = {}
  13. local function createPlayerRequestEncoder(msg)
  14. local input = roleHandler_pb.CreatePlayerRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function createPlayerRequestDecoder(stream)
  19. local res = roleHandler_pb.CreatePlayerResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.RoleHandler.createPlayerRequest(c2s_pro,c2s_name,c2s_sex,cb,option)
  24. local msg = {}
  25. msg.c2s_pro = c2s_pro
  26. msg.c2s_name = c2s_name
  27. msg.c2s_sex = c2s_sex
  28. Socket.OnRequestStart("connector.roleHandler.createPlayerRequest", option)
  29. Socket.Request("connector.roleHandler.createPlayerRequest", msg, function(res)
  30. if(res.s2c_code == 200) then
  31. Pomelo.RoleHandler.lastCreatePlayerResponse = res
  32. Socket.OnRequestEnd("connector.roleHandler.createPlayerRequest", 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] connector.roleHandler.createPlayerRequest decode error!!"
  42. end
  43. Socket.OnRequestEnd("connector.roleHandler.createPlayerRequest", false,ex.Code,ex.Message)
  44. cb(ex,nil)
  45. end
  46. end, createPlayerRequestEncoder, createPlayerRequestDecoder)
  47. end
  48. local function changePlayerNameRequestEncoder(msg)
  49. local input = roleHandler_pb.ChangePlayerNameRequest()
  50. protobuf.FromMessage(input,msg)
  51. return (input:SerializeToString())
  52. end
  53. local function changePlayerNameRequestDecoder(stream)
  54. local res = roleHandler_pb.ChangePlayerNameResponse()
  55. res:ParseFromString(stream)
  56. return res
  57. end
  58. function Pomelo.RoleHandler.changePlayerNameRequest(c2s_name,pos,cb,option)
  59. local msg = {}
  60. msg.c2s_name = c2s_name
  61. msg.pos = pos
  62. Socket.OnRequestStart("connector.roleHandler.changePlayerNameRequest", option)
  63. Socket.Request("connector.roleHandler.changePlayerNameRequest", msg, function(res)
  64. if(res.s2c_code == 200) then
  65. Pomelo.RoleHandler.lastChangePlayerNameResponse = res
  66. Socket.OnRequestEnd("connector.roleHandler.changePlayerNameRequest", 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] connector.roleHandler.changePlayerNameRequest decode error!!"
  76. end
  77. Socket.OnRequestEnd("connector.roleHandler.changePlayerNameRequest", false,ex.Code,ex.Message)
  78. cb(ex,nil)
  79. end
  80. end, changePlayerNameRequestEncoder, changePlayerNameRequestDecoder)
  81. end
  82. local function deletePlayerRequestEncoder(msg)
  83. local input = roleHandler_pb.DeletePlayerRequest()
  84. protobuf.FromMessage(input,msg)
  85. return (input:SerializeToString())
  86. end
  87. local function deletePlayerRequestDecoder(stream)
  88. local res = roleHandler_pb.DeletePlayerResponse()
  89. res:ParseFromString(stream)
  90. return res
  91. end
  92. function Pomelo.RoleHandler.deletePlayerRequest(c2s_playerId,cb,option)
  93. local msg = {}
  94. msg.c2s_playerId = c2s_playerId
  95. Socket.OnRequestStart("connector.roleHandler.deletePlayerRequest", option)
  96. Socket.Request("connector.roleHandler.deletePlayerRequest", msg, function(res)
  97. if(res.s2c_code == 200) then
  98. Pomelo.RoleHandler.lastDeletePlayerResponse = res
  99. Socket.OnRequestEnd("connector.roleHandler.deletePlayerRequest", 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] connector.roleHandler.deletePlayerRequest decode error!!"
  109. end
  110. Socket.OnRequestEnd("connector.roleHandler.deletePlayerRequest", false,ex.Code,ex.Message)
  111. cb(ex,nil)
  112. end
  113. end, deletePlayerRequestEncoder, deletePlayerRequestDecoder)
  114. end
  115. local function getRandomNameRequestEncoder(msg)
  116. local input = roleHandler_pb.GetRandomNameRequest()
  117. protobuf.FromMessage(input,msg)
  118. return (input:SerializeToString())
  119. end
  120. local function getRandomNameRequestDecoder(stream)
  121. local res = roleHandler_pb.GetRandomNameResponse()
  122. res:ParseFromString(stream)
  123. return res
  124. end
  125. function Pomelo.RoleHandler.getRandomNameRequest(c2s_sex,cb,option)
  126. local msg = {}
  127. msg.c2s_sex = c2s_sex
  128. Socket.OnRequestStart("connector.roleHandler.getRandomNameRequest", option)
  129. Socket.Request("connector.roleHandler.getRandomNameRequest", msg, function(res)
  130. if(res.s2c_code == 200) then
  131. Pomelo.RoleHandler.lastGetRandomNameResponse = res
  132. Socket.OnRequestEnd("connector.roleHandler.getRandomNameRequest", true)
  133. cb(nil,res)
  134. else
  135. local ex = {}
  136. if(res.s2c_code) then
  137. ex.Code = res.s2c_code
  138. ex.Message = res.s2c_msg
  139. else
  140. ex.Code = 501
  141. ex.Message = "[LuaXmdsNetClient] connector.roleHandler.getRandomNameRequest decode error!!"
  142. end
  143. Socket.OnRequestEnd("connector.roleHandler.getRandomNameRequest", false,ex.Code,ex.Message)
  144. cb(ex,nil)
  145. end
  146. end, getRandomNameRequestEncoder, getRandomNameRequestDecoder)
  147. end
  148. --------------------------------Pomelo-------------------------------
  149. return Pomelo