void CNetwork::start() { QMutexLocker l(&m_pSection); if(m_bActive) { systemLog.postLog(LogSeverity::Debug, "Network already started"); return; } m_bActive = true; m_oAddress.setPort(quazaaSettings.Connection.Port); Handshakes.listen(); m_oRoutingTable.clear(); connect(&ShareManager, SIGNAL(sharesReady()), this, SLOT(onSharesReady()), Qt::UniqueConnection); NetworkThread.start("Network", &m_pSection, this); Datagrams.moveToThread(&NetworkThread); SearchManager.moveToThread(&NetworkThread); Neighbours.moveToThread(&NetworkThread); Neighbours.connectNode(); }
void CNetwork::Connect() { QMutexLocker l(&m_pSection); if(m_bActive) { systemLog.postLog(LogSeverity::Debug, "Network already started"); //qDebug() << "Network already started"; return; } if(quazaaSettings.Gnutella2.ClientMode < 2) { m_nNodeState = G2_LEAF; } else { m_nNodeState = G2_HUB; } m_bActive = true; m_oAddress.setPort(quazaaSettings.Connection.Port); m_nNextCheck = quazaaSettings.Gnutella2.AdaptiveCheckPeriod; m_nBusyPeriods = 0; m_nTotalPeriods = 0; Handshakes.Listen(); m_oRoutingTable.Clear(); m_nSecsToHubBalancing = HUB_BALANCING_INTERVAL; m_tLastModeChange = time(0); m_nMinutesAbove90 = m_nMinutesBelow50 = 0; m_nMinutesTrying = 0; connect(&ShareManager, SIGNAL(sharesReady()), this, SLOT(OnSharesReady()), Qt::UniqueConnection); connect(&Datagrams, SIGNAL(PacketQueuedForRouting()), this, SLOT(RoutePackets()), Qt::QueuedConnection); Datagrams.moveToThread(&NetworkThread); NetworkThread.start("Network", &m_pSection, this); SearchManager.moveToThread(&NetworkThread); Neighbours.moveToThread(&NetworkThread); Neighbours.Connect(); }