/*----------------------------------------------- *本文件由代码生成器自动生成, *千万不要修改本文件的任何代码, *修改的的任何代码都会被覆盖掉! --------------------------------------------------*/ using System.IO; using System; using System.Collections.Generic; using System.Linq; using System.Text; using Pomelo.DotNetClient; namespace pomelo.redpacket { public class RedPacketHandler { private PomeloClient _socket; public GetRedPacketListResponse lastGetRedPacketListResponse { get { return _socket.GetLastResponse(); } } public DispatchRedPacketResponse lastDispatchRedPacketResponse { get { return _socket.GetLastResponse(); } } public FetchRedPacketResponse lastFetchRedPacketResponse { get { return _socket.GetLastResponse(); } } static RedPacketHandler() { EventTypes.RegistPushType("redpacket.redPacketPush.onRedPacketDispatchPush", typeof(OnRedPacketDispatchPush)); EventTypes.RegistRequestType("redpacket.redPacketHandler.getRedPacketListRequest", typeof(GetRedPacketListRequest), typeof(GetRedPacketListResponse)); EventTypes.RegistRequestType("redpacket.redPacketHandler.dispatchRedPacketRequest", typeof(DispatchRedPacketRequest), typeof(DispatchRedPacketResponse)); EventTypes.RegistRequestType("redpacket.redPacketHandler.fetchRedPacketRequest", typeof(FetchRedPacketRequest), typeof(FetchRedPacketResponse)); } public RedPacketHandler(PomeloClient socket) { this._socket = socket; } public void getRedPacketListRequest(Action cb,object option = null) { var request = new GetRedPacketListRequest(); _socket.request(request, (object msg, out int s2c_code, out string s2c_msg) => { var rsp = msg as GetRedPacketListResponse; s2c_code = rsp.s2c_code; s2c_msg = rsp.s2c_msg; return s2c_code == 200; }, cb, option); } public void dispatchRedPacketRequest(int count,int totalNum,int channelType,int fetchType,int benifitType,string message,Action cb,object option = null) { var request = new DispatchRedPacketRequest(); request.count= count; request.totalNum= totalNum; request.channelType= channelType; request.fetchType= fetchType; request.benifitType= benifitType; request.message= message; _socket.request(request, (object msg, out int s2c_code, out string s2c_msg) => { var rsp = msg as DispatchRedPacketResponse; s2c_code = rsp.s2c_code; s2c_msg = rsp.s2c_msg; return s2c_code == 200; }, cb, option); } public void fetchRedPacketRequest(string id,Action cb,object option = null) { var request = new FetchRedPacketRequest(); request.id= id; _socket.request(request, (object msg, out int s2c_code, out string s2c_msg) => { var rsp = msg as FetchRedPacketResponse; s2c_code = rsp.s2c_code; s2c_msg = rsp.s2c_msg; return s2c_code == 200; }, cb, option); } public void onRedPacketDispatchPush(Action cb) { _socket.listen_once(cb); } } }