CNeighbour* CNeighboursConnections::OnAccept(CNetworkConnection* pConn)
{
	// TODO: Make new CNeighbour deriviate for handshaking with Gnutella clients

	systemLog.postLog(LogSeverity::Debug, "CNeighbours::OnAccept");
	//qDebug() << "CNeighbours::OnAccept";

	if(!m_bActive)
	{
		pConn->Close();
		return 0;
	}

	if(!m_pSection.tryLock(50))
	{
		systemLog.postLog(LogSeverity::Debug, "Not accepting incoming connection. Neighbours overloaded");
		pConn->Close();
		return 0;
	}

	CG2Node* pNew = new CG2Node();
	pNew->AttachTo(pConn);
	AddNode(pNew);
	pNew->moveToThread(&NetworkThread);

	m_pSection.unlock();

	return pNew;
}
void CNetwork::ConnectTo(CEndPoint& addr)
{
	// TODO: Verify network is connected before attempting connection and create connection if it is not
	CG2Node* pNew = Neighbours.ConnectTo(addr);

	if(pNew)
	{
		pNew->moveToThread(&NetworkThread);
	}
}