Ejemplo n.º 1
0
void CPlayer::OnPlayerDisconnect()
{
    m_nDisconnectTime = time(NULL) ;
    // inform components;
    for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
    {
        IPlayerComponent* p = m_vAllComponents[i] ;
        if ( p )
        {
            p->OnPlayerDisconnect();
        }
    }

    OnTimerSave(nullptr,0);
    m_tTimerSave.canncel() ;

    SetState(ePlayerState_Offline) ;
    LOGFMTE("player disconnect should inform other sever");

    // save log
    stMsgSaveLog msgLog ;
    memset(msgLog.vArg,0,sizeof(msgLog.vArg));
    msgLog.nJsonExtnerLen = 0 ;
    msgLog.nLogType = eLog_PlayerLogOut ;
    msgLog.nTargetID = GetUserUID() ;
    memset(msgLog.vArg,0,sizeof(msgLog.vArg));
    msgLog.vArg[0] = GetBaseData()->getCoin() ;
    msgLog.vArg[1] = GetBaseData()->GetAllDiamoned();
    SendMsgToClient((char*)&msgLog,sizeof(msgLog));
}
Ejemplo n.º 2
0
void CPlayer::OnPlayerDisconnect()
{
	// inform components;
	for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
	{
		IPlayerComponent* p = m_vAllComponents[i] ;
		if ( p )
		{
			p->OnPlayerDisconnect();
		}
	}

	if ( m_pTimerSave )
	{
		m_pTimerSave->Stop();
	}
	
	m_nDisconnectTime = time(NULL) ;
	SetState(ePlayerState_Offline) ;

	if ( m_nTaxasRoomID != 0 )  // order to leave 
	{
		stMsgOrderTaxasPlayerLeave msgLeave ;
		msgLeave.nRoomID = m_nTaxasRoomID ;
		CGameServerApp::SharedGameServerApp()->SendMsg(GetSessionID(),(char*)&msgLeave,sizeof(msgLeave) ) ;
	}
}