void Client::connect() {
	if(socket)
		BufferedSocket::putSocket(socket);

	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	try {
		socket = BufferedSocket::getSocket(separator);
		socket->addListener(this);
		socket->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
	} catch(const Exception& e) {
		if(socket) {
			BufferedSocket::putSocket(socket);
			socket = 0;
		}
		fire(ClientListener::Failed(), this, e.getError());
	}
	updateActivity();
	state = STATE_CONNECTING;
}
Exemple #2
0
void Client::connect() {
	if (sock) {
		BufferedSocket::putSocket(sock);
		sock = 0;
	}

	redirectUrl = Util::emptyString;
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	setConnectState(STATE_CONNECTING);

	try {
		sock = BufferedSocket::getSocket(separator, v4only());
		sock->addListener(this);
		sock->connect(Socket::AddressInfo(address, Socket::AddressInfo::TYPE_URL), port, secure, SETTING(ALLOW_UNTRUSTED_HUBS), true, keyprint /**/);
	} catch (const Exception& e) {
		setConnectState(STATE_DISCONNECTED);
		fire(ClientListener::Failed(), hubUrl, e.getError());
	}
	updateActivity();
}
Exemple #3
0
void Client::connect()
{
	reset_socket();
	// [!]IRainman moved to two function:
	// void Client::on(Failed, const string& aLine)
	// void Client::disconnect(bool graceLess)
	clearAvailableBytes();
	
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	const FavoriteHubEntry* fhe = reloadSettings(true);
	// [!]IRainman fix.
	resetRegistered(); // [!]
	resetOp(); // [+]
	// [-] setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); [-]
	// [-] setHubIdentity(Identity()); [-]
	// [~] IRainman fix.
	
	state = STATE_CONNECTING;
	
	try
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		m_client_sock = BufferedSocket::getBufferedSocket(m_separator);
		m_client_sock->addListener(this);
		m_client_sock->connect(m_address,
		                       m_port,
		                       m_secure,
		                       BOOLSETTING(ALLOW_UNTRUSTED_HUBS),
		                       true);
		dcdebug("Client::connect() %p\n", (void*)this);
	}
	catch (const Exception& e)
	{
		state = STATE_DISCONNECTED;
		fire(ClientListener::Failed(), this, e.getError());
	}
	m_isActivMode = ClientManager::isActive(fhe); // [+] IRainman opt.
	updateActivity();
}
Exemple #4
0
void Client::connect() {
    if(sock)
        BufferedSocket::putSocket(sock);

    setAutoReconnect(true);
    setReconnDelay(SETTING(RECONNECT_DELAY));
    reloadSettings(true);
    setRegistered(false);
    setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
    setHubIdentity(Identity());

    state = STATE_CONNECTING;

    try {
        sock = BufferedSocket::getSocket(separator);
        sock->addListener(this);
        sock->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
    } catch(const Exception& e) {
        shutdown();
        /// @todo at this point, this hub instance is completely useless
        fire(ClientListener::Failed(), this, e.getError());
    }
    updateActivity();
}
void Client::reconnect() {
	disconnect(true);
	setAutoReconnect(true);
	setReconnDelay(0);
}