#include "NetCli_FriendList.h"

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

//--------------------------------------------------------------------------------------------------------------------------------------
bool NetCli_FriendList::_Init()
{
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_ChattoC_BefriendRequest	         , _PG_Friend_ChattoC_BefriendRequest	           );
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_LtoC_AddFriend			         , _PG_Friend_LtoC_AddFriend			           );
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_LtoC_DelFriend			         , _PG_Friend_LtoC_DelFriend			           );
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_LtoC_FriendList			         , _PG_Friend_LtoC_FriendList			           );

	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_ChattoC_PlayerOnline			     , _PG_Friend_ChattoC_PlayerOnline			       );
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_ChattoC_PlayerOffline		     , _PG_Friend_ChattoC_PlayerOffline		           );
	_Net.RegOnSrvPacketFunction	( EM_PG_Friend_ChattoC_ModifyInfo				 , _PG_Friend_ChattoC_ModifyInfo				   );

	_Net.RegOnSrvDisConnectFunction		( OnEvent_ServerDisConnect	);
    return true;
}
//--------------------------------------------------------------------------------------------------------------------------------------
bool NetCli_FriendList::_Release()
{
    return true;
}
//--------------------------------------------------------------------------------------------------------------------------------------
void NetCli_FriendList::OnEvent_ServerDisConnect		( int ServerID )
{
	This->OnServerDisConnect( ServerID );
}

void NetCli_FriendList::_PG_Friend_ChattoC_PlayerOnline		( int Sockid , int Size , void* Data )
{
	PG_Friend_ChattoC_PlayerOnline *  PG = (PG_Friend_ChattoC_PlayerOnline *)Data;

	This->RChat_PlayerOnline( (char*)PG->RoleName.Begin() , (char*)PG->Note.Begin() , PG->ZoneID , PG->Look , PG->Voc , PG->Voc_Sub , PG->LV , PG->LV_Sub , PG->Sex );
}
void NetCli_FriendList::_PG_Friend_ChattoC_PlayerOffline	( int Sockid , int Size , void* Data )
{
	PG_Friend_ChattoC_PlayerOffline *  PG = (PG_Friend_ChattoC_PlayerOffline *)Data;
	This->RChat_PlayerOffline( (char*)PG->RoleName.Begin() );

}
void NetCli_FriendList::_PG_Friend_ChattoC_ModifyInfo		( int Sockid , int Size , void* Data )
{
	PG_Friend_ChattoC_ModifyInfo *  PG = (PG_Friend_ChattoC_ModifyInfo *)Data;
	This->RChat_ModifyInfo(  (char*)PG->RoleName.Begin() , (char*)PG->Note.Begin() , PG->ZoneID , PG->Voc , PG->Voc_Sub , PG->LV , PG->LV_Sub , PG->Sex );

}

void NetCli_FriendList::_PG_Friend_ChattoC_BefriendRequest	( int Sockid , int Size , void* Data )
{
	PG_Friend_ChattoC_BefriendRequest *  PG = (PG_Friend_ChattoC_BefriendRequest *)Data;
	This->RChat_BefriendRequest( (char*)PG->Name.Begin() );
}
void NetCli_FriendList::_PG_Friend_LtoC_AddFriend			( int Sockid , int Size , void* Data )		
{
	PG_Friend_LtoC_AddFriend *  PG = (PG_Friend_LtoC_AddFriend *)Data;
	This->RL_AddFriend( (char*)PG->FriendName.Begin() );
}
void NetCli_FriendList::_PG_Friend_LtoC_DelFriend			( int Sockid , int Size , void* Data )		
{
	PG_Friend_LtoC_DelFriend *  PG = (PG_Friend_LtoC_DelFriend *)Data;
	This->RL_DelFriend( (char*)PG->FriendName.Begin() );
}
void NetCli_FriendList::_PG_Friend_LtoC_FriendList			( int Sockid , int Size , void* Data )
{
	PG_Friend_LtoC_FriendList *  PG = (PG_Friend_LtoC_FriendList *)Data;
	This->RL_FriendList( PG->FriendList );
}
//--------------------------------------------------------------------------------------------------------------------------------------
void NetCli_FriendList::SChat_BefriendRequest	( char* Name )
{
	PG_Friend_CtoChat_BefriendRequest Send;
	Send.Name = Name;

	SendToChat( sizeof(Send) , &Send );
}
void NetCli_FriendList::SChat_BefriendResult	( char* Name , bool Result )
{
	PG_Friend_CtoChat_BefriendResult Send;
	Send.Name = Name;
	Send.Result = Result;

	SendToChat( sizeof(Send) , &Send );
}
void NetCli_FriendList::SL_DelFriend			( char* Name )
{
	PG_Friend_CtoL_DelFriend Send;
	Send.FriendName = Name;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_FriendList::SL_ModifyMyInfo			( char* Note )
{
	PG_Friend_CtoL_ModifyMyInfo Send;
	Send.Note = Note;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_FriendList::SL_AddBadFriend			( char* Name )
{
	PG_Friend_CtoL_AddBadFriend Send;
	Send.RoleName = Name;

	SendToLocal( sizeof(Send) , &Send );
}
void NetCli_FriendList::SL_DelBadFriend			( char* Name )
{
	PG_Friend_CtoL_DelBadFriend Send;
	Send.RoleName = Name;

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

void NetCli_FriendList::SL_SetFriendInfo		( char* Name , char* Group , char* Note )
{
	PG_Friend_CtoL_SetFriendInfo Send;
	Send.FriendName = Name;
	Send.Type = Group;
	Send.Note = Note;
	SendToLocal( sizeof(Send) , &Send );
}