Exemple #1
0
BOOL ServerManager::ProcessOutputs( )
{
__ENTER_FUNCTION

    BOOL ret = FALSE ;

    if (m_MinFD == INVALID_SOCKET && m_MaxFD == INVALID_SOCKET) // no player exist
    { 
        return TRUE ;
    }

    //数据发送
    UINT nPlayerCount = GetPlayerNumber() ;
    for( UINT i=0; i<nPlayerCount; i++ )
    {
        if( m_pPlayers[i]==INVALID_ID )
            continue ;

        ServerPlayer* pPlayer = g_pPlayerPool->GetPlayer(m_pPlayers[i]) ;
        Assert( pPlayer ) ;

        SOCKET s = pPlayer->GetSocket()->getSOCKET() ;
        if( s == m_SocketID )
            continue ;

        if( FD_ISSET( s, &m_WriteFDs[SELECT_USE] ) )
        {
            if( pPlayer->GetSocket()->isSockError() )
            {//连接出现错误
                RemovePlayer( pPlayer ) ;
            }
            else
            {//连接正常
                _MY_TRY
                {
                    ret = pPlayer->ProcessOutput( ) ;
                    if( !ret )
                    {
                        RemovePlayer( pPlayer ) ;
                    }
                }
                _MY_CATCH
                {
                    RemovePlayer( pPlayer ) ;
                }
            }
        }
    }

    return TRUE ;

__LEAVE_FUNCTION

    return FALSE ;
}
Exemple #2
0
bool ServerManager::ProcessExceptions( )
{
	if(m_MinFD == INVALID_SOCKET && m_MaxFD == INVALID_SOCKET)
	{
		return true;
	}

	for(int i=SCENE_PLAYER_ID; i<=BILLING_PLAYER_ID; i++)
	{
		ServerPlayer*	pPlayer = GetServerPlayer(i);
		if(!pPlayer) continue;

		if(pPlayer->IsValid())
		{
			SOCKET s = pPlayer->GetSocket()->getSOCKET();
			if(FD_ISSET( s, &m_ExceptFDs[SELECT_USE]) )
			{
				g_pLog->log_debug("%u,%u,ProcessException......",pPlayer->PlayerID(),0);
				RemoveServer(i);
			}
		}
	}

	return true;
}
Exemple #3
0
bool ServerManager::ProcessCommands( )
{
	bool ret = false;

	if(m_MinFD == INVALID_SOCKET && m_MaxFD == INVALID_SOCKET)
	{
		return true;
	}

	for(int i=SCENE_PLAYER_ID; i<=BILLING_PLAYER_ID; i++)
	{
		ServerPlayer*	pPlayer = GetServerPlayer(i);
		if(!pPlayer) continue;

		if(pPlayer->IsValid())
		{
			if(pPlayer->GetSocket()->isSockError() )
			{
				RemoveServer(i);
			}
			else
			{
				ret = pPlayer->ProcessCommand(false);
				if(!ret)
				{
					RemoveServer( i );
				}
			}
		}
	}

	return true;
}
Exemple #4
0
bool ServerManager::ProcessOutputs( )
{
	bool ret = false;

	if(m_MinFD == INVALID_SOCKET && m_MaxFD == INVALID_SOCKET)
	{
		return true;
	}

	for(int i=SCENE_PLAYER_ID; i<=BILLING_PLAYER_ID; i++)
	{
		ServerPlayer*	pPlayer = GetServerPlayer(i);
		if(!pPlayer) continue;

		if(pPlayer->IsValid())
		{
			SOCKET s = pPlayer->GetSocket()->getSOCKET();
			if(FD_ISSET( s, &m_WriteFDs[SELECT_USE]) )
			{
				if(pPlayer->GetSocket()->isSockError() )
				{
					RemoveServer(i);
				}
				else
				{
					ret = pPlayer->ProcessOutput( );
					if(!ret)
					{
						RemoveServer( i );
					}
				}
			}
		}
	}

	return true;
}