Exemple #1
0
/**
  * Register or update a child with the given socket and his child depth
  */
void Museek::SearchManager::setChild(DistributedSocket * socket, uint depth) {
    if (socket) {
        bool isUpdate = m_Children.find(socket->user()) != m_Children.end();
        if ((parent() || isUpdate) && acceptChildren()) {
            NNLOG("museekd.peers.debug", "Setting child: %s, depth %d", socket->user().c_str(), depth);

            uint oldDepth = childDepth();

            m_Children[socket->user()] = std::pair<NewNet::RefPtr<DistributedSocket>, uint>(socket, depth);
            uint newDepth = childDepth();

            if (oldDepth != newDepth) {
                NNLOG("museekd.peers.debug", "Our child depth is now %d", newDepth);
                SChildDepth msg(newDepth);
                museekd()->server()->sendMessage(msg.make_network_packet());

                if (parent()) {
                    DChildDepth msgP(newDepth);
                    parent()->sendMessage(msgP.make_network_packet());
                }
            }

            if (!isUpdate) {
                socket->disconnectedEvent.connect(this, &SearchManager::onChildDisconnected);
                socket->setPingTimeout(museekd()->reactor()->addTimeout(60000, socket, &DistributedSocket::ping));

                // We have reached our maximum number of children
                if (m_Children.size() >= m_ChildrenMaxNumber) {
                    SAcceptChildren msgA(false);
                    museekd()->server()->sendMessage(msgA.make_network_packet());
                }
            }
        }
        else {
            // We want to disconnect this socket. BUT we have to be sure that there isn't any remaining handshakesocket in the reactor
            // before doing this (If there is still a handshake socket, it will stay in the reactor even if it's a dead socket so there
            // will be problems. This happens if the peer sends us both HInitiate and DChildDepth message at once.).
            // To be sure of that, wait 1 second before disconnecting
            socket->addDisconnectNowTimeout();
        }
    }
}
	void 
	SDFRigidTransform::accept(SDFNodeVisitor &nv)
	{
		nv.visit(this);
        acceptChildren(nv);
	}
Exemple #3
0
void RuleNode::accept(BuildGraphVisitor *visitor)
{
    if (visitor->visit(this))
        acceptChildren(visitor);
    visitor->endVisit(this);
}