/**
  * Sends our position in the soulseek search tree
  */
void newsoul::DistributedSocket::sendPosition() {
    DBranchLevel msgL(newsoul()->searches()->branchLevel());
    sendMessage(msgL.make_network_packet());

    DBranchRoot msgR(newsoul()->searches()->branchRoot());
    sendMessage(msgR.make_network_packet());
}
Beispiel #2
0
/**
  * We have a new branch root, store it and notify the server
  */
void Museek::SearchManager::setBranchRoot(const std::string & root) {
    NNLOG("museekd.peers.debug", "Our branch root is %s", root.c_str());
    m_BranchRoot = root;

    // Tell our new parent how many children we've got
    DChildDepth msgD(childDepth());
    parent()->sendMessage(msgD.make_network_packet());

    // Send out parent IP to the server
    SParentIP msgIp(m_ParentIp);
    museekd()->server()->sendMessage(msgIp.make_network_packet());
    // Send our branch level to the server
    SBranchLevel msgL(branchLevel());
    museekd()->server()->sendMessage(msgL.make_network_packet());
    // Send the new branch root to the server
    SBranchRoot msgR(root);
    museekd()->server()->sendMessage(msgR.make_network_packet());

    // Tell our children what we've done
    std::map<std::string, std::pair<NewNet::RefPtr<DistributedSocket>, uint> >::iterator cit;
    for (cit = m_Children.begin(); cit != m_Children.end(); cit++) {
        if (cit->second.first.isValid())
            cit->second.first->sendPosition();
    }
}
Beispiel #3
0
/**
  * Our connection with our parent has been disconnected
  */
void Museek::SearchManager::onParentDisconnected(NewNet::ClientSocket * socket_) {
    m_BranchRoot = museekd()->server()->username();
    setBranchLevel(0);

    setParent(0);

    SAcceptChildren msgAccept(false);
    museekd()->server()->sendMessage(msgAccept.make_network_packet());

    SChildDepth msgD(childDepth());
    museekd()->server()->sendMessage(msgD.make_network_packet());

    SHaveNoParents msgH(true);
    museekd()->server()->sendMessage(msgH.make_network_packet());

    SBranchLevel msgL(branchLevel());
    museekd()->server()->sendMessage(msgL.make_network_packet());

    SBranchRoot msgR(branchRoot());
    museekd()->server()->sendMessage(msgR.make_network_packet());
}
Beispiel #4
0
MessageResult Editor::message(const T& msgAcc)
{
    const Message & msg = msgAcc.message();

    switch (msg.msgId)
    {
    case HASH::key_press:
    {
        messages::KeyPressR<T> msgR(msgAcc);
        processKeyPress(msgR.keys());
        break;
    }
    case HASH::fin:
    {
        InputMgr::deregister_key_press_listener(HASH::editor__, mTask.id());
        break;
    }
    default:
        PANIC("Unknown Editor message: %d", msg.msgId);
    }

    return MessageResult::Consumed;
}