示例#1
0
void dazeus::Network::checkTimeouts() {
	if(deadline_ > time(NULL)) {
		return; // deadline is set, not passed
	}
	if(deadline_ == 0) {
		if(time(NULL) > nextPongDeadline_) {
			// We've passed the nextPongDeadline, send the next PING
			nextPongDeadline_ = time(NULL) + 30;
			deadline_ = time(NULL) + config_->pongTimeout;
			activeServer_->ping();
		}
		return;
	}

	// Connection didn't finish in time, disconnect and try again
	flagUndesirableServer(activeServer()->config());
	activeServer_->disconnectFromServer(dazeus::Network::TimeoutReason);
	onFailedConnection();
	// no need to delete the server later, though: we can do it from here
	// TODO: use smart ptrs so this mess gets elegant by refcounting
	deleteServer_ = false;
	delete activeServer_;
	activeServer_ = 0;
	connectToNetwork(true);
}
Core::NotificationManager::NotificationManager(QObject *p)
    : QObject(p)
    , server(0)
    , renderer(0)
{
    timer=new QTimer(this);
    timer->setSingleShot(true);
    connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(Upnp::Model::self()->serversModel(), SIGNAL(activeDevice(QModelIndex)), this, SLOT(activeServer(QModelIndex)));
    connect(Upnp::Model::self()->renderersModel(), SIGNAL(activeDevice(QModelIndex)), this, SLOT(activeRenderer(QModelIndex)));
}