FileTransferController::FileTransferController(QObject *parent) : QObject(parent) { connect(skynet, SIGNAL(IncomingFileRequestReceived(QByteArray,quint64,QString)), this, SLOT(file_request(QByteArray,quint64,QString))); connect(skynet, SIGNAL(FileProgress(QByteArray,quint64,quint64)), this, SLOT(file_progress(QByteArray,quint64,quint64))); connect(skynet, SIGNAL(OutgoingFileRequestAccepted(QByteArray)), this, SLOT(file_accepted_by_peer(QByteArray))); connect(skynet, SIGNAL(OutgoingFileRequestDenied(QByteArray)), this, SLOT(file_denied_by_peer(QByteArray))); connect(skynet, SIGNAL(ChannelClosed(QByteArray)), this, SLOT(file_peer_disconnected(QByteArray))); }
void CKadLookup::Process(UINT Tick) { if((Tick & E10PerSec) == 0) return; uint64 uNow = GetCurTick(); // check out all open channels int ActiveNodes = 0; for(TNodeStatusMap::iterator I = m_Nodes.begin(); I != m_Nodes.end(); I++) { if(!I->first.pChannel) continue; // Note: a sub node is not allowed to disconnect on its during a lookup, if it does so its considdered a failure if(I->first.pChannel->IsDisconnected()) { I->first.pChannel = NULL; I->first.pNode->IncrFailed(); if(I->second->uTimeOut != 0) NodeStalling(I->first.pNode); ChannelClosed(I->first.pNode); if(I->second->LookupState == eLookupClosest) { ASSERT(m_ClosestNodes > 0); m_ClosestNodes--; } } else { if(I->second->uTimeOut < uNow) { if(I->second->uTimeOut != 0) { NodeStalling(I->first.pNode); I->second->uTimeOut = 0; // mark this node as stalled } } else if(I->second->LookupState == eLookupActive) ActiveNodes++; // active node requests that are not stalled } } if(m_LookupState != eLookupActive) return; int AskForCloser = GetNeededCount(); AskForCloser -= Min(AskForCloser, ActiveNodes + m_ClosestNodes); ASSERT(AskForCloser >= 0); CRoutingZone::SIterator Iter; for(CKadNode* pNode; (pNode = GetParent<CKademlia>()->Root()->GetClosestNode(Iter, m_ID)) && AskForCloser > 0;) { if(WasNodeUsed(pNode)) continue; if(RequestNodes(pNode, CKadLookup::GetChannel(pNode))) { AskForCloser --; ActiveNodes++; } } // are we done, doer cause we got what we wanted or cause there isnt any more if(ActiveNodes == 0) m_LookupState = eLookupFinished; }
void SkyNet::emit_ChannelClosed(QByteArray peer_id) { emit ChannelClosed(peer_id); }