void SSCDControl::incomingConnection (int descriptor) { ClientSocket *clientSocket = new ClientSocket(descriptor, db, this); //TODO: Implement the "ForceEncryption" setting which only allows encrypted settings //(configuration item) // socket->setProtocol(QSsl::SslV2); // socket->setCiphers(Settings::getS("Cipher")); // socket->startServerEncryption(); // socket->ignoreSslErrors(); connect(clientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionClosing(QAbstractSocket::SocketState))); clients << clientSocket; }
void Connection::onDataRead(std::size_t size) { resetTimeoutTimer(); for (int i = 0; i < size; i++) { char byte = buff_[i]; try { current_request_->feedByte(byte); } catch (HTTPRequest::RequestReady &) { boost::system::error_code ec; current_request_->setIPAddress(client_socket_->remote_endpoint(ec).address().to_string()); if (ec) { connectionClosing(); return; } std::shared_ptr<HTTPResponse> response(new HTTPResponse); application_pointer_->onNewRequest(*current_request_, response); sendResponse(response.get()); logResponse(current_request_, response); current_request_.reset(new HTTPRequest); } catch (HTTPRequest::HeaderFormatError &) { current_request_.reset(new HTTPRequest); } } }
void Connection::onTimerExpires() { boost::system::error_code ec; BOOST_LOG_TRIVIAL(debug) << "Connection timeout " << client_socket_->remote_endpoint(ec); connectionClosing(); }