Пример #1
0
//-------------------------------------------------------------------------------------
bool Proxy::sendToClient(bool expectData)
{
	if(!clientMailbox())
		return false;

	Mercury::Channel* pChannel = clientMailbox()->getChannel();
	if(!pChannel)
		return false;

	if(expectData)
	{
		if(pChannel->bundles().size() == 0)
		{
			WARNING_MSG("Proxy::sendToClient: no data!\n");
			return false;
		}
	}

	{
		// 如果数据大量阻塞发不出去将会报警
		AUTO_SCOPED_PROFILE("sendToClient");
		pChannel->send();
	}

	return true;
}
Пример #2
0
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
	lockthread();

	if(hasBufferedLogPackets_ == 0)
	{
		unlockthread();
		return;
	}

	if(Mercury::Address::NONE == messagelogAddr_)
	{
		if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}
		
		canLogFile_ = true;
		unlockthread();
		return;
	}
	
	Mercury::Channel* pMessagelogChannel = pNetworkInterface_->findChannel(messagelogAddr_);
	if(pMessagelogChannel == NULL)
	{
		if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}
		
		canLogFile_ = true;
		unlockthread();
		return;
	}

	int8 v = Mercury::g_trace_packet;
	Mercury::g_trace_packet = 0;

	uint32 i = 0;
	size_t totalLen = 0;

	while(!bufferedLogPackets_.empty())
	{
		if(i++ >= g_kbeSrvConfig.tickMaxSyncLogs() || totalLen > (PACKET_MAX_SIZE_TCP * 10))
			break;
		
		Mercury::Bundle* pBundle = bufferedLogPackets_.front();
		bufferedLogPackets_.pop();

		totalLen += pBundle->currMsgLength();
		pMessagelogChannel->send(pBundle);
		
		--hasBufferedLogPackets_;
	}

	Mercury::g_trace_packet = v;
	canLogFile_ = false;
	unlockthread();
}
Пример #3
0
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
	if(bufferedLogPackets_.size() == 0)
		return;

	if(Mercury::Address::NONE == messagelogAddr_)
	{
		if(bufferedLogPackets_.size() > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}

		return;
	}
	
	Mercury::Channel* pMessagelogChannel = pNetworkInterface_->findChannel(messagelogAddr_);
	if(pMessagelogChannel == NULL)
	{
		if(bufferedLogPackets_.size() > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}

		return;
	}

	int8 v = Mercury::g_trace_packet;
	Mercury::g_trace_packet = 0;

	uint32 i = 0;
	size_t totalLen = 0;

	std::list< Mercury::Bundle* >::iterator iter = bufferedLogPackets_.begin();
	for(; iter != bufferedLogPackets_.end();)
	{
		if(i++ >= g_kbeSrvConfig.tickMaxSyncLogs() || totalLen > (PACKET_MAX_SIZE_TCP * 10))
			break;
		
		totalLen += (*iter)->currMsgLength();
		pMessagelogChannel->send((*iter));
		
		bufferedLogPackets_.erase(iter++); 
	}

	Mercury::g_trace_packet = v;
}
Пример #4
0
//-------------------------------------------------------------------------------------
void Witness::update()
{
	SCOPED_PROFILE(CLIENT_UPDATE_PROFILE);

	if(pEntity_ == NULL)
		return;

	if(!pEntity_->getClientMailbox())
		return;

	Mercury::Channel* pChannel = pEntity_->getClientMailbox()->getChannel();
	if(!pChannel)
		return;

	{
		// 如果数据大量阻塞发不出去将会报警
		AUTO_SCOPED_PROFILE("updateClientSend");
		pChannel->send();
	}
}
int ChannelClientApp::handleTimeout( Mercury::TimerID id, void * arg )
{
	ServerInterface::msg1Args & args =
		ServerInterface::msg1Args::start( pChannel_->bundle() );

	args.traits = pChannel_->traits();
	args.seq = outSeq_++;
	args.data = 0;

	if (outSeq_ == numToSend_)
	{
		ServerInterface::disconnectArgs & args =
			ServerInterface::disconnectArgs::start( pChannel_->bundle() );

		args.seq = outSeq_;
		this->stopTimer();
		pChannel_->isIrregular( true );
	}

	pChannel_->send();

	return 0;
}
Пример #6
0
//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
    if(bufferedLogPackets_.size() == 0)
        return;

    if(messagelogAddr_.isNone())
    {
        if(bufferedLogPackets_.size() > 128)
        {
            ERROR_MSG("DebugHelper::sync: can't found messagelog. packet size=%u.\n", bufferedLogPackets_.size());
            clearBufferedLog();
        }
        return;
    }

    int8 v = Mercury::g_trace_packet;
    Mercury::g_trace_packet = 0;

    Mercury::Channel* pChannel = pNetworkInterface_->findChannel(messagelogAddr_);
    if(pChannel == NULL)
    {
        if(bufferedLogPackets_.size() > 1024)
        {
            messagelogAddr_.ip = 0;
            messagelogAddr_.port = 0;

            WARNING_MSG("DebugHelper::sync: is no use the messagelog, packet size=%u.\n",
                        bufferedLogPackets_.size());
            clearBufferedLog();
        }

        Mercury::g_trace_packet = v;
        return;
    }

    if(bufferedLogPackets_.size() > 0)
    {
        if(bufferedLogPackets_.size() > 32)
        {
            WARNING_MSG("DebugHelper::sync: packet size=%u.\n", bufferedLogPackets_.size());
        }

        int i = 0;

        size_t totalLen = 0;

        std::list< Mercury::Bundle* >::iterator iter = bufferedLogPackets_.begin();
        for(; iter != bufferedLogPackets_.end();)
        {
            if(i++ >= 32 || totalLen > (PACKET_MAX_SIZE_TCP * 10))
                break;

            totalLen += (*iter)->currMsgLength();
            pChannel->send((*iter));

            Mercury::Bundle::ObjPool().reclaimObject((*iter));
            bufferedLogPackets_.erase(iter++);
        }
    }

    Mercury::g_trace_packet = v;
}