RichHandler.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.rich
  13. {
  14. public class RichHandler
  15. {
  16. private PomeloClient _socket;
  17. public GetRichInfoResponse lastGetRichInfoResponse { get { return _socket.GetLastResponse<GetRichInfoResponse>(); } }
  18. public DiceResponse lastDiceResponse { get { return _socket.GetLastResponse<DiceResponse>(); } }
  19. public FetchTurnAwardResponse lastFetchTurnAwardResponse { get { return _socket.GetLastResponse<FetchTurnAwardResponse>(); } }
  20. static RichHandler()
  21. {
  22. EventTypes.RegistRequestType("rich.richHandler.getRichInfoRequest", typeof(GetRichInfoRequest), typeof(GetRichInfoResponse));
  23. EventTypes.RegistRequestType("rich.richHandler.diceRequest", typeof(DiceRequest), typeof(DiceResponse));
  24. EventTypes.RegistRequestType("rich.richHandler.fetchTurnAwardRequest", typeof(FetchTurnAwardRequest), typeof(FetchTurnAwardResponse));
  25. }
  26. public RichHandler(PomeloClient socket)
  27. {
  28. this._socket = socket;
  29. }
  30. public void getRichInfoRequest(Action<PomeloException,GetRichInfoResponse> cb,object option = null)
  31. {
  32. var request = new GetRichInfoRequest();
  33. _socket.request<GetRichInfoResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  34. var rsp = msg as GetRichInfoResponse;
  35. s2c_code = rsp.s2c_code;
  36. s2c_msg = rsp.s2c_msg;
  37. return s2c_code == 200;
  38. }, cb, option);
  39. }
  40. public void diceRequest(Action<PomeloException,DiceResponse> cb,object option = null)
  41. {
  42. var request = new DiceRequest();
  43. _socket.request<DiceResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  44. var rsp = msg as DiceResponse;
  45. s2c_code = rsp.s2c_code;
  46. s2c_msg = rsp.s2c_msg;
  47. return s2c_code == 200;
  48. }, cb, option);
  49. }
  50. public void fetchTurnAwardRequest(int id,Action<PomeloException,FetchTurnAwardResponse> cb,object option = null)
  51. {
  52. var request = new FetchTurnAwardRequest();
  53. request.id= id;
  54. _socket.request<FetchTurnAwardResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  55. var rsp = msg as FetchTurnAwardResponse;
  56. s2c_code = rsp.s2c_code;
  57. s2c_msg = rsp.s2c_msg;
  58. return s2c_code == 200;
  59. }, cb, option);
  60. }
  61. }
  62. }