RankHandler.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*-----------------------------------------------
  2. *本文件由代码生成器自动生成,
  3. *千万不要修改本文件的任何代码,
  4. *修改的的任何代码都会被覆盖掉!
  5. --------------------------------------------------*/
  6. using System.IO;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using Pomelo.DotNetClient;
  12. namespace pomelo.area
  13. {
  14. public class RankHandler
  15. {
  16. private PomeloClient _socket;
  17. public GetRankInfoResponse lastGetRankInfoResponse { get { return _socket.GetLastResponse<GetRankInfoResponse>(); } }
  18. static RankHandler()
  19. {
  20. EventTypes.RegistPushType("area.rankPush.onAwardRankPush", typeof(OnAwardRankPush));
  21. EventTypes.RegistRequestType("area.rankHandler.getRankInfoRequest", typeof(GetRankInfoRequest), typeof(GetRankInfoResponse));
  22. EventTypes.RegistNotifyType("area.rankHandler.saveRankNotify", typeof(SaveRankNotify));
  23. }
  24. public RankHandler(PomeloClient socket)
  25. {
  26. this._socket = socket;
  27. }
  28. public void getRankInfoRequest(Action<PomeloException,GetRankInfoResponse> cb,object option = null)
  29. {
  30. var request = new GetRankInfoRequest();
  31. _socket.request<GetRankInfoResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  32. var rsp = msg as GetRankInfoResponse;
  33. s2c_code = rsp.s2c_code;
  34. s2c_msg = rsp.s2c_msg;
  35. return s2c_code == 200;
  36. }, cb, option);
  37. }
  38. public void saveRankNotify(int c2s_selectedRankId)
  39. {
  40. var notify = new SaveRankNotify();
  41. notify.c2s_selectedRankId= c2s_selectedRankId;
  42. _socket.notify(notify);
  43. }
  44. public void onAwardRankPush(Action<OnAwardRankPush> cb)
  45. {
  46. _socket.listen_once<OnAwardRankPush>(cb);
  47. }
  48. }
  49. }