/**
@SYMTestCaseID          PDS-EFM-UT-4113
@SYMTestCaseDesc        Unit test for client reference counting.
@SYMTestPriority        High
@SYMTestActions         Create CFeatureDiscovery object and check the client reference count
                        Connect using RFeatureControl and check the client reference count
                        Delete the CFeatureDiscovery object and check the client reference count
                        Close RFeatureControl and check the client reference count
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144262
*/  
void TestRefCountCFeatureDiscoveryL()
    {
        RFeatureControl featCtrl;
        CleanupClosePushL(featCtrl);
        CFeatureDiscovery* featDisc = CFeatureDiscovery::NewLC();    
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        featCtrl.Connect();
        TEST2 (GetClientCount(), 2); // Client count should be 2 at this point

        // Both should return same result
        TEST2 (featDisc->IsSupported(KDummyFeatUid), featCtrl.FeatureSupported(KDummyFeatUid)==KFeatureSupported);
        
        CleanupStack::PopAndDestroy(featDisc);
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        
        CleanupStack::PopAndDestroy(&featCtrl);
        TEST2 (GetClientCount(), 0); // Client count should be 0 at this point
    }
/**
@SYMTestCaseID          PDS-EFM-UT-4112
@SYMTestCaseDesc        Unit test for client reference counting.
@SYMTestPriority        High
@SYMTestActions         Initialise FeatureManager and check the client reference count
                        Connect using RFeatureControl and check the client reference count
                        Uninitialise FeatureManager and check the client reference count
                        Close RFeatureControl and check the client reference count
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144262
*/  
void TestRefCountFeatureManagerL()
    {
        RFeatureControl featCtrl;    
        
        CleanupClosePushL(featCtrl);
        FeatureManager::InitializeLibL();
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        
        featCtrl.Connect();
        TEST2 (GetClientCount(), 2); // Client count should be 2 at this point
        
        // Both should return same result
        TEST2 (FeatureManager::FeatureSupported(KDummyFeatUid.iUid), featCtrl.FeatureSupported(KDummyFeatUid)==KFeatureSupported);
        
        FeatureManager::UnInitializeLib();
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        
        CleanupStack::PopAndDestroy(&featCtrl);
        TEST2 (GetClientCount(), 0); // Client count should be 0 at this point
    }
void TazanServer::DoAccept()
{
	Acceptor.async_accept(AcceptedSocket,
		[this](boost::system::error_code ec)
	{
		if (!ec)
		{
			Lock lock(lockSource);

			AcceptedSocket.set_option(option_nodelay);
			
			std::make_shared<Client>(std::move(AcceptedSocket))->OnConnected((TazanServer*)this);
			printf("A Client Connected, Count : %d\n", GetClientCount());
		}

		DoAccept();
	});
}
void MMatchServer::OnMatchLoginFromNetmarbleJP(const MUID& CommUID, const char* szLoginID, const char* szLoginPW, int nCmdVersion, unsigned long nChecksumPack)
{
	bool bFreeLoginIP = false;
	string strCountryCode3;

	// 프로토콜, 최대인원 체크
	if (!CheckOnLoginPre(CommUID, nCmdVersion, bFreeLoginIP, strCountryCode3)) return;

	// DBAgent에 먼저 보내고 응답을 받으면 로그인 프로세스를 진행한다.
	if (!MGetLocale()->PostLoginInfoToDBAgent(CommUID, szLoginID, szLoginPW, bFreeLoginIP, nChecksumPack, GetClientCount()))
	{
		mlog( "Server user full(DB agent error).\n" );
		MCommand* pCmd = CreateCmdMatchResponseLoginFailed(CommUID, MERR_CLIENT_FULL_PLAYERS);
		Post(pCmd);
		return;
	}
}