RankHandler.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. -------------------------------------------------
  2. -- 本文件由代码生成器自动生成,
  3. -- 千万不要修改本文件的任何代码,
  4. -- 修改的的任何代码都会被覆盖掉!
  5. ----------------------------------------------------
  6. local Socket = require "Xmds.Pomelo.LuaGameSocket"
  7. require "base64"
  8. require "rankHandler_pb"
  9. --------------------------------Pomelo-------------------------------
  10. Pomelo = Pomelo or {}
  11. --------------------------------RankHandler-------------------------------
  12. Pomelo.RankHandler = {}
  13. local function getRankInfoRequestEncoder(msg)
  14. local input = rankHandler_pb.GetRankInfoRequest()
  15. protobuf.FromMessage(input,msg)
  16. return (input:SerializeToString())
  17. end
  18. local function getRankInfoRequestDecoder(stream)
  19. local res = rankHandler_pb.GetRankInfoResponse()
  20. res:ParseFromString(stream)
  21. return res
  22. end
  23. function Pomelo.RankHandler.getRankInfoRequest(cb,option)
  24. local input = nil
  25. Socket.OnRequestStart("area.rankHandler.getRankInfoRequest", option)
  26. Socket.Request("area.rankHandler.getRankInfoRequest", input, function(res)
  27. if(res.s2c_code == 200) then
  28. Pomelo.RankHandler.lastGetRankInfoResponse = res
  29. Socket.OnRequestEnd("area.rankHandler.getRankInfoRequest", 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.rankHandler.getRankInfoRequest decode error!!"
  39. end
  40. Socket.OnRequestEnd("area.rankHandler.getRankInfoRequest", false,ex.Code,ex.Message)
  41. cb(ex,nil)
  42. end
  43. end, getRankInfoRequestEncoder, getRankInfoRequestDecoder)
  44. end
  45. local function saveRankNotifyEncoder(msg)
  46. local input = rankHandler_pb.SaveRankNotify()
  47. protobuf.FromMessage(input,msg)
  48. return (input:SerializeToString())
  49. end
  50. function Pomelo.RankHandler.saveRankNotify(c2s_selectedRankId)
  51. local msg = {}
  52. msg.c2s_selectedRankId = c2s_selectedRankId
  53. Socket.Notify("area.rankHandler.saveRankNotify", msg, saveRankNotifyEncoder)
  54. end
  55. local function onAwardRankPushDecoder(stream)
  56. local res = rankHandler_pb.OnAwardRankPush()
  57. res:ParseFromString(stream)
  58. return res
  59. end
  60. function Pomelo.RankHandler.onAwardRankPush(cb)
  61. Socket.On("area.rankPush.onAwardRankPush", function(res)
  62. Pomelo.RankHandler.lastOnAwardRankPush = res
  63. cb(nil,res)
  64. end, onAwardRankPushDecoder)
  65. end
  66. --------------------------------Pomelo-------------------------------
  67. return Pomelo