MailHandler.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 MailHandler
  15. {
  16. private PomeloClient _socket;
  17. public MailGetAllResponse lastMailGetAllResponse { get { return _socket.GetLastResponse<MailGetAllResponse>(); } }
  18. public MailSendMailResponse lastMailSendMailResponse { get { return _socket.GetLastResponse<MailSendMailResponse>(); } }
  19. public MailDeleteResponse lastMailDeleteResponse { get { return _socket.GetLastResponse<MailDeleteResponse>(); } }
  20. public MailDeleteOneKeyResponse lastMailDeleteOneKeyResponse { get { return _socket.GetLastResponse<MailDeleteOneKeyResponse>(); } }
  21. public MailGetAttachmentResponse lastMailGetAttachmentResponse { get { return _socket.GetLastResponse<MailGetAttachmentResponse>(); } }
  22. public MailGetAttachmentOneKeyResponse lastMailGetAttachmentOneKeyResponse { get { return _socket.GetLastResponse<MailGetAttachmentOneKeyResponse>(); } }
  23. static MailHandler()
  24. {
  25. EventTypes.RegistPushType("area.mailPush.onGetMailPush", typeof(OnGetMailPush));
  26. EventTypes.RegistRequestType("area.mailHandler.mailGetAllRequest", typeof(MailGetAllRequest), typeof(MailGetAllResponse));
  27. EventTypes.RegistRequestType("area.mailHandler.mailSendMailRequest", typeof(MailSendMailRequest), typeof(MailSendMailResponse));
  28. EventTypes.RegistRequestType("area.mailHandler.mailDeleteRequest", typeof(MailDeleteRequest), typeof(MailDeleteResponse));
  29. EventTypes.RegistRequestType("area.mailHandler.mailDeleteOneKeyRequest", typeof(MailDeleteOneKeyRequest), typeof(MailDeleteOneKeyResponse));
  30. EventTypes.RegistRequestType("area.mailHandler.mailGetAttachmentRequest", typeof(MailGetAttachmentRequest), typeof(MailGetAttachmentResponse));
  31. EventTypes.RegistRequestType("area.mailHandler.mailGetAttachmentOneKeyRequest", typeof(MailGetAttachmentOneKeyRequest), typeof(MailGetAttachmentOneKeyResponse));
  32. EventTypes.RegistNotifyType("area.mailHandler.mailReadNotify", typeof(MailReadNotify));
  33. EventTypes.RegistNotifyType("area.mailHandler.mailSendTestNotify", typeof(MailSendTestNotify));
  34. }
  35. public MailHandler(PomeloClient socket)
  36. {
  37. this._socket = socket;
  38. }
  39. public void mailGetAllRequest(Action<PomeloException,MailGetAllResponse> cb,object option = null)
  40. {
  41. var request = new MailGetAllRequest();
  42. _socket.request<MailGetAllResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  43. var rsp = msg as MailGetAllResponse;
  44. s2c_code = rsp.s2c_code;
  45. s2c_msg = rsp.s2c_msg;
  46. return s2c_code == 200;
  47. }, cb, option);
  48. }
  49. public void mailSendMailRequest(string toPlayerId,string mailTitle,string mailText,int mailRead,string toPlayerName,Action<PomeloException,MailSendMailResponse> cb,object option = null)
  50. {
  51. var request = new MailSendMailRequest();
  52. request.toPlayerId= toPlayerId;
  53. request.mailTitle= mailTitle;
  54. request.mailText= mailText;
  55. request.mailRead= mailRead;
  56. request.toPlayerName= toPlayerName;
  57. _socket.request<MailSendMailResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  58. var rsp = msg as MailSendMailResponse;
  59. s2c_code = rsp.s2c_code;
  60. s2c_msg = rsp.s2c_msg;
  61. return s2c_code == 200;
  62. }, cb, option);
  63. }
  64. public void mailDeleteRequest(string c2s_id,Action<PomeloException,MailDeleteResponse> cb,object option = null)
  65. {
  66. var request = new MailDeleteRequest();
  67. request.c2s_id= c2s_id;
  68. _socket.request<MailDeleteResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  69. var rsp = msg as MailDeleteResponse;
  70. s2c_code = rsp.s2c_code;
  71. s2c_msg = rsp.s2c_msg;
  72. return s2c_code == 200;
  73. }, cb, option);
  74. }
  75. public void mailDeleteOneKeyRequest(Action<PomeloException,MailDeleteOneKeyResponse> cb,object option = null)
  76. {
  77. var request = new MailDeleteOneKeyRequest();
  78. _socket.request<MailDeleteOneKeyResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  79. var rsp = msg as MailDeleteOneKeyResponse;
  80. s2c_code = rsp.s2c_code;
  81. s2c_msg = rsp.s2c_msg;
  82. return s2c_code == 200;
  83. }, cb, option);
  84. }
  85. public void mailGetAttachmentRequest(string c2s_id,Action<PomeloException,MailGetAttachmentResponse> cb,object option = null)
  86. {
  87. var request = new MailGetAttachmentRequest();
  88. request.c2s_id= c2s_id;
  89. _socket.request<MailGetAttachmentResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  90. var rsp = msg as MailGetAttachmentResponse;
  91. s2c_code = rsp.s2c_code;
  92. s2c_msg = rsp.s2c_msg;
  93. return s2c_code == 200;
  94. }, cb, option);
  95. }
  96. public void mailGetAttachmentOneKeyRequest(Action<PomeloException,MailGetAttachmentOneKeyResponse> cb,object option = null)
  97. {
  98. var request = new MailGetAttachmentOneKeyRequest();
  99. _socket.request<MailGetAttachmentOneKeyResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
  100. var rsp = msg as MailGetAttachmentOneKeyResponse;
  101. s2c_code = rsp.s2c_code;
  102. s2c_msg = rsp.s2c_msg;
  103. return s2c_code == 200;
  104. }, cb, option);
  105. }
  106. public void mailReadNotify(List<string> c2s_id)
  107. {
  108. var notify = new MailReadNotify();
  109. notify.c2s_id.AddRange(c2s_id);
  110. _socket.notify(notify);
  111. }
  112. public void mailSendTestNotify(int c2s_mailId,string c2s_tcCode)
  113. {
  114. var notify = new MailSendTestNotify();
  115. notify.c2s_mailId= c2s_mailId;
  116. notify.c2s_tcCode= c2s_tcCode;
  117. _socket.notify(notify);
  118. }
  119. public void onGetMailPush(Action<OnGetMailPush> cb)
  120. {
  121. _socket.listen_once<OnGetMailPush>(cb);
  122. }
  123. }
  124. }