Exemplo n.º 1
0
void Peer::HandleResponses(WMessagePtr pWMsg)
{
	MessagePtr pMsg = pWMsg->GetMsg();

	// get the peer list if given in message
	std::vector<RemotePeers> peerList = pMsg->m_peerList;
	if( peerList.size() > 0 ) {
		long ts = pMsg->m_timestamp;
		this->HandlePeerList(peerList, ts);
	}

	// see if it is a task message
	if( pMsg->IsTaskMessage() ) {
		int msgTaskId = pMsg->m_taskId;
		// get the task and forward the message
		std::map<int, TaskPtr>::iterator it;
		it = m_taskList.find(msgTaskId);
		if( it != m_taskList.end() ) {
			TaskPtr pTask = (*it).second;
			pTask->GetMessageQueue()->PutMessage(pWMsg);
		}
		else {
			Log(CONSOLE, L"No Task Related to Task Response Message Received for taskId: %d\n", msgTaskId);
		}
		return;
	}

	switch(pMsg->m_respType) {
		case GET_ONLINE_RESP:
			HandleOnlineResp(pMsg);
			break;
		default:
			break;
	}
}
Exemplo n.º 2
0
// handle the connection failures
void Peer::HandleConnectionFailure(WMessagePtr pMsg)
{
	// see to which peer-node the connection failed
	// see if there is any task been alloted to that peer
	// see if there is any job been executed for that peer

	int failedConnPeer = pMsg->GetPeerId();
	// get the task and forward the failure message
	std::map<int, TaskPtr>::iterator it = m_taskList.begin();
	for( ;it != m_taskList.end(); it++ ) {
		TaskPtr pTask = (*it).second;
		pTask->GetMessageQueue()->PutMessage(pMsg);
	}
}
Exemplo n.º 3
0
void Peer::HandleTaskResult(WMessagePtr pWMsg)
{
	MessagePtr pMsg = pWMsg->GetMsg();
	Log(CONSOLE, L"Handling Task Result from Peer: %d, taskid: %d\n", 
											pMsg->m_fromPeerId, pMsg->m_taskId);

	PeerNodePtr pNode = pMsg->m_conn->GetPeerNode();
	// get the task and forward the message
	std::map<int, TaskPtr>::iterator it;
	it = m_taskList.find(pMsg->m_taskId);
	if( it != m_taskList.end() ) {
		TaskPtr pTask = (*it).second;
		pTask->GetMessageQueue()->PutMessage(pWMsg);
	}
	else {
		Log(CONSOLE, L"No Task Related to Task Result Message Received for taskId: %d\n", pMsg->m_taskId);
	}
}