/*-----------------------------------------------
 *本文件由代码生成器自动生成,
 *千万不要修改本文件的任何代码,
 *修改的的任何代码都会被覆盖掉!
 --------------------------------------------------*/

using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pomelo.DotNetClient;

namespace pomelo.growing
{
	public class GrowingHandler
	{
		private PomeloClient _socket;

		public GetGrowingResponse lastGetGrowingResponse { get { return _socket.GetLastResponse<GetGrowingResponse>(); } }
		public GrowingAwardResponse lastGrowingAwardResponse { get { return _socket.GetLastResponse<GrowingAwardResponse>(); } }
		static GrowingHandler()
		{
			EventTypes.RegistPushType("growing.growingPush.updateGrowingPush", typeof(UpdateGrowingPush));
			EventTypes.RegistPushType("growing.growingPush.curChapterPush", typeof(CurChapterPush));
			EventTypes.RegistPushType("growing.growingPush.updateGrowingValuePush", typeof(UpdateGrowingValuePush));
			EventTypes.RegistRequestType("growing.growingHandler.getGrowingRequest", typeof(GetGrowingRequest), typeof(GetGrowingResponse));
			EventTypes.RegistRequestType("growing.growingHandler.growingAwardRequest", typeof(GrowingAwardRequest), typeof(GrowingAwardResponse));
		}
		public GrowingHandler(PomeloClient socket)
		{
			this._socket = socket;

		}
		public void getGrowingRequest(Action<PomeloException,GetGrowingResponse> cb,object option = null)
		{
			var request = new GetGrowingRequest();
			_socket.request<GetGrowingResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
				var rsp = msg as GetGrowingResponse;
				s2c_code = rsp.s2c_code;
				s2c_msg = rsp.s2c_msg;
				return s2c_code == 200;
			}, cb, option);

		}
		public void growingAwardRequest(int c2s_optionType,int c2s_parameter,Action<PomeloException,GrowingAwardResponse> cb,object option = null)
		{
			var request = new GrowingAwardRequest();
			request.c2s_optionType= c2s_optionType;
			request.c2s_parameter= c2s_parameter;
			_socket.request<GrowingAwardResponse>(request, (object msg, out int s2c_code, out string s2c_msg) => {
				var rsp = msg as GrowingAwardResponse;
				s2c_code = rsp.s2c_code;
				s2c_msg = rsp.s2c_msg;
				return s2c_code == 200;
			}, cb, option);

		}
		public void onUpdateGrowingPush(Action<UpdateGrowingPush> cb)
		{
			_socket.listen_once<UpdateGrowingPush>(cb);
		}
		public void onCurChapterPush(Action<CurChapterPush> cb)
		{
			_socket.listen_once<CurChapterPush>(cb);
		}
		public void onUpdateGrowingValuePush(Action<UpdateGrowingValuePush> cb)
		{
			_socket.listen_once<UpdateGrowingValuePush>(cb);
		}

	}


}