void SshConnectionPrivate::handleIncomingData() { if (m_state == SocketUnconnected) return; // For stuff queued in the event loop after we've called closeConnection(); try { if (!canUseSocket()) return; m_incomingData += m_socket->readAll(); #ifdef CREATOR_SSH_DEBUG qDebug("state = %d, remote data size = %d", m_state, m_incomingData.count()); #endif if (m_serverId.isEmpty()) handleServerId(); handlePackets(); } catch (SshServerException &e) { closeConnection(e.error, SshProtocolError, e.errorStringServer, tr("SSH Protocol error: %1").arg(e.errorStringUser)); } catch (SshClientException &e) { closeConnection(SSH_DISCONNECT_BY_APPLICATION, e.error, "", e.errorString); } catch (Botan::Exception &e) { closeConnection(SSH_DISCONNECT_BY_APPLICATION, SshInternalError, "", tr("Botan library exception: %1").arg(QString::fromLatin1(e.what()))); } }
void Server::run() { sf::Clock stepClock, syncClock; sf::Time elapsedStep = sf::Time::Zero, elapsedSync = sf::Time::Zero; while (true) { handleNewConnection(); handleDisconnection(); handlePackets(); elapsedStep += stepClock.restart(); elapsedSync += syncClock.restart(); while (elapsedStep >= TimeStep) { elapsedStep -= TimeStep; mGame.step(*this); } while (elapsedSync >= TimeSync) { elapsedSync -= TimeSync; mGame.sync(*this); } } }
void Server::run() { ENetEvent event; std::cout << "Actual port => " << _set.getCvar("sv_port") << std::endl; std::cout << "Quiet => " << _set.getCvar("sv_quiet") << std::endl; std::cout << "Debug => " << _set.getCvar("sv_debug") << std::endl; while ((enet_host_service(_server, &event, 50)) >= 0) { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: connectClient(event.peer); break; case ENET_EVENT_TYPE_RECEIVE: handlePackets(event); break; case ENET_EVENT_TYPE_DISCONNECT: disconnectClient(event.peer); default: break; } updateClients(); } }
void PlayingState::handleEvent(Application & app) { sf::Event ev; while (app.getWindow().pollEvent(ev)) { if (ev.type == sf::Event::Closed) app.quit(); m_game.handleEvent(ev); } handlePackets(app); }