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); }
void dazeus::Network::processDescriptors(fd_set *in_set, fd_set *out_set) { if(deleteServer_) { deleteServer_ = false; delete activeServer_; activeServer_ = 0; connectToNetwork(); return; } activeServer_->processDescriptors(in_set, out_set); }
Link::Link(const std::string& linkType, const std::string& linkParams, Output* srcOutput, Input* destInput) { commonConstructorInit_(linkType, linkParams, srcOutput->getRegion().getName(), destInput->getRegion().getName(), srcOutput->getName(), destInput->getName() ); connectToNetwork(srcOutput, destInput); // Note -- link is not usable until we set the destOffset, which happens at initialization time }
void Player::setGameMode(std::string myip, unsigned short myport , bool startmode, std::string otherip, unsigned short otherport, int _numPlayers, int _numAIs) { if(startmode) { startNetwork(myip, myport); numPlayers = _numPlayers; numAIs = _numAIs; nameAI = settings->name; didStart = true; } else { connectToNetwork(otherip, otherport, myip, myport); didStart = false; } }
void MainWindow::connectOrSend() { // Si el boton connectOrSend tiene la leyenda "Connect", mostrar el cuadro dialogo para // solicitar los datos de conexion. Si tiene la leyenda "Send" se envia un mensaje ui->connectOrSendButton->text() == tr("&Connect") ? connectToNetwork() : sendMessage(); }