#include "NetCli_Mail.h"

//-------------------------------------------------------------------
NetCli_Mail*    NetCli_Mail::This         = NULL;

//-------------------------------------------------------------------
bool NetCli_Mail::_Init()
{

	_Net.RegOnSrvPacketFunction	( EM_PG_Mail_LtoC_SendMailResult        , _PG_Mail_LtoC_SendMailResult  );
	_Net.RegOnSrvPacketFunction	( EM_PG_Mail_LtoC_GetItemResult	        , _PG_Mail_LtoC_GetItemResult	  );
	_Net.RegOnSrvPacketFunction	( EM_PG_Mail_DtoC_MailListResult        , _PG_Mail_DtoC_MailListResult  );
	_Net.RegOnSrvPacketFunction	( EM_PG_Mail_DtoC_MailListCountResult   , _PG_Mail_DtoC_MailListCountResult  );
	//_Net.RegOnSrvPacketFunction	( EM_PG_Mail_DtoC_ReadMailResult        , _PG_Mail_DtoC_ReadMailResult  );
    return true;
}
//-------------------------------------------------------------------
bool NetCli_Mail::_Release()
{
    return true;
}
//-------------------------------------------------------------------
void NetCli_Mail::_PG_Mail_LtoC_SendMailResult	( int Sockid , int Size , void* Data )
{
	PG_Mail_LtoC_SendMailResult* PG = (PG_Mail_LtoC_SendMailResult*) Data;
	This->RL_SendMailResult( PG->Result );
}
void NetCli_Mail::_PG_Mail_LtoC_GetItemResult	( int Sockid , int Size , void* Data )
{
	PG_Mail_LtoC_GetItemResult* PG = (PG_Mail_LtoC_GetItemResult*) Data;
	This->RL_GetItemResult( PG->MailDBID , PG->Result );
}
void NetCli_Mail::_PG_Mail_DtoC_MailListResult	( int Sockid , int Size , void* Data )
{
	PG_Mail_DtoC_MailListResult* PG = (PG_Mail_DtoC_MailListResult*) Data;

	This->RD_MailListResult( PG->MailDBID , PG->Index , PG->MailBaseInfo , (char*)PG->Content.Begin() );

}
void NetCli_Mail::_PG_Mail_DtoC_MailListCountResult	( int Sockid , int Size , void* Data )
{
	PG_Mail_DtoC_MailListCountResult* PG = (PG_Mail_DtoC_MailListCountResult*) Data;

	This->RD_MailListCountResult( PG->MaxCount , PG->Count);

}
/*
void NetCli_Mail::_PG_Mail_DtoC_ReadMailResult	( int Sockid , int Size , void* Data )
{
	PG_Mail_DtoC_ReadMailResult* PG = (PG_Mail_DtoC_ReadMailResult*) Data;

	This->RD_ReadMailResult( PG->MailDBID , PG->MailBaseInfo , (char*)PG->Content.Begin() , PG->Result );
}
*/
//-------------------------------------------------------------------
void NetCli_Mail::SL_SendMail	( MailBaseInfoStruct& MailBaseInfo , int ItemPos , char* Content )
{
	PG_Mail_CtoL_SendMail Send;
	Send.MailBaseInfo = MailBaseInfo;
	Send.ItemPos = ItemPos;
	Send.Content = Content;
	Send.ContentSize = Send.Content.Size()+1;

	SendToLocal( Send.PGSize() , &Send );
}
void NetCli_Mail::SL_MailList	(  )
{
	PG_Mail_CtoL_MailList Send;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Mail::SL_SendBack	( int MailDBID )
{
	PG_Mail_CtoL_SendBack Send;
	Send.MailDBID = MailDBID;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Mail::SL_DelMail	( int MailDBID )
{
	PG_Mail_CtoL_DelMail Send;
	Send.MailDBID = MailDBID;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Mail::SL_ReadMail	( int MailDBID )
{
	PG_Mail_CtoL_ReadMail Send;
	Send.MailDBID = MailDBID;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_Mail::SL_GetItem	( int MailDBID , int Money )
{
	PG_Mail_CtoL_GetItem Send;
	Send.MailDBID = MailDBID;
	Send.Money = Money;

	SendToLocal( sizeof(Send) , &Send );
}
//-------------------------------------------------------------------