示例#1
0
void Robot::CommandProc()
{
	ChannelMap::iterator iter = m_commandReceivingChannels.begin();
    ChannelMap::iterator end = m_commandReceivingChannels.end();
    for (; iter != end; iter++)
	{
		RobotCommandBase* cmdBase[2];
		euint size = 0;
		RWBuffer channel = iter->second;
		while (RWBuffer_Read(channel, (euint*)cmdBase, &size))
		{
			if (size >= sizeof(RobotCommandBase*)) {
				RobotCommand* cmd =
                cmdBase[0]->DynamicCast<RobotCommand>();
				if (cmd) {
                    CommandProcImpl(iter->first, cmd);
				    delete cmd;
					break;
				}
				RobotCommandReceipt* rec =
                cmdBase[0]->DynamicCast<RobotCommandReceipt>();
				if (rec) {
					CommandReceiptProcImpl(iter->first, rec);
					delete rec;
				}
			}
		}
	}
}
示例#2
0
void RobotManager::BreakChannel(xhn::static_string sender,
                                xhn::static_string receiver)
{
	xhn::RWLock2::Instance inst = m_readwriteLock.GetWriteLock();
	RobotMap::iterator r = m_robotMap.find(receiver);
	if (r != m_robotMap.end()) {
		Robot* rRob = r->second;
		rRob->m_commandReceivingChannels.erase(sender);
	}
	RobotMap::iterator s = m_robotMap.find(sender);
	if (s != m_robotMap.end()) {
		Robot* sRob = r->second;
		Robot::ChannelMap::iterator iter =
        sRob->m_commandTransmissionChannels.find(receiver);
        
		if (iter != sRob->m_commandTransmissionChannels.end()) {
			RobotCommand* cmd[2];
			euint size = 0;
			RWBuffer channel = iter->second;
			while (RWBuffer_Read(channel, (euint*)cmd, &size)) {
				if (size >= sizeof(RobotCommand*))
					delete cmd[0];
			}
			RWBuffer_delete(iter->second);
		}
	}
}
示例#3
0
文件: robot.cpp 项目: vengine/XGC
char* SafedBuffer::Read(euint* readSize)
{
	if (RWBuffer_Read(m_buffer, (euint*)m_transferBuffer, readSize))
		return m_transferBuffer;
	else
		return NULL;
}
示例#4
0
void InputListener::Listen()
{
	euint size = 0;
    while (RWBuffer_Read(m_input_buffer, (euint*)m_read_buffer, &size))
	{
        euint count = size / sizeof(input_event);
		for (euint i = 0; i < count; i++)
		{
			ListenImpl(m_read_buffer[i]);
		}
	}
}