void NodeNetworkSystem::serverRemoveSessionHandler(Session* session) {
	switch (_nodeProcessingSystem->getNodeType()) {
	case NODETYPE_SINK: {
		NetworkNode* camera = NetworkNode::getCameraBySession(session);
		if (camera) {
			if (_DEBUG)
				cout << "NodeNetworkSystem::serverAddSessionHandler: Camera "
						<< (unsigned short) camera->getId() << " disconnected "
						<< endl;
			camera->setSession(NULL);
		}
		break;
	}
	case NODETYPE_CAMERA: {
		NetworkNode* cooperator = NetworkNode::getCooperatorBySession(session);
		if (cooperator) {
			if (_DEBUG)
				cout
						<< "NodeNetworkSystem::serverAddSessionHandler: Cooperator "
						<< (unsigned short) cooperator->getId()
						<< " disconnected " << endl;
			cooperator->setSession(NULL);
			_offloadingManager->removeCooperator(cooperator);
			CoopInfoMsg* infoMsg = new CoopInfoMsg(NetworkNode::getMyself(),
					NetworkNode::getSink(), LINKTYPE_TCP,
					_offloadingManager->getCooperatorsIds());
			sendMessage(infoMsg);
		}
		break;
	}
	default: {
		if (_DEBUG)
			cerr << "NodeNetworkSystem::serverAddSessionHandler: Node of type "
					<< _nodeProcessingSystem->getNodeType()
					<< " can't reach this point" << endl;
	}
	}
}
/**
 * A client component has connected. Notify the server this node
 */
void NodeNetworkSystem::clientConnectHandler(Session* session) {
	if (_DEBUG)
		cout << "NodeNetworkSystem::clientConnectHandler" << endl;

	NetworkNode* serverNode = NetworkNode::getNodeBySession(session);
	NetworkNode* myself = NetworkNode::getMyself();

	NodeInfoMsg* msg = new NodeInfoMsg(myself, serverNode, LINKTYPE_TCP,
			myself->getId(), myself->getAmAddr(),
			session->getSocket()->local_endpoint().address().to_string(),
			session->getSocket()->local_endpoint().port(), myself->getType());

	session->writeMessage(msg);

	if (myself->getType() == NODETYPE_CAMERA) {
		CoopInfoMsg* infoMsg = new CoopInfoMsg(NetworkNode::getMyself(),
				NetworkNode::getSink(), LINKTYPE_TCP,
				_offloadingManager->getCooperatorsIds());
		sendMessage(infoMsg);
	}

}