void CTIServer::disconnectFromServer() { m_socket->flush(); disconnect(m_socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); m_socket->disconnectFromHost(); if (m_socket->isEncrypted() && m_socket->state() != QAbstractSocket::UnconnectedState) m_socket->waitForDisconnected(); connect(m_socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); }
void ServiceDirectoryClient::onSDEventConnected(qi::Future<SignalLink> future, qi::Promise<void> promise, bool isAdd) { if (promise.future().isFinished()) { return; } if (future.hasError()) { qi::Future<void> fdc = onSocketDisconnected(future.error()); fdc.connect(&qi::Promise<void>::setError, promise, future.error()); return; } bool ready = false; { boost::mutex::scoped_lock lock(_mutex); if (isAdd) _addSignalLink = future.value(); else _removeSignalLink = future.value(); ready = _addSignalLink && _removeSignalLink; } if (ready) { promise.setValue(0); connected(); } }
void AuthHandler::setSocket(QTcpSocket *socket) { _socket = socket; connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SIGNAL(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); }
void HIDServer::onInterruptChannelConnected() { qDebug() << "NEW Interrupt connection"; m_interruptSocket = m_interruptChannel.nextPendingConnection(); connect(m_interruptSocket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); updateConnectionState(); }
QXmppIncomingClient::QXmppIncomingClient (QSslSocket *socket, const QString &domain, QObject *parent) : QXmppStream (parent) { bool check; Q_UNUSED (check); d = new QXmppIncomingClientPrivate (this); d->domain = domain; if (socket) { check = connect (socket, SIGNAL (disconnected()), this, SLOT (onSocketDisconnected())); Q_ASSERT (check); setSocket (socket); } info (QString ("Incoming client connection from %1").arg (d->origin())); // create inactivity timer d->idleTimer = new QTimer (this); d->idleTimer->setSingleShot (true); check = connect (d->idleTimer, SIGNAL (timeout()), this, SLOT (onTimeout())); Q_ASSERT (check); }
void HIDServer::onControlChannelConnected() { qDebug() << "NEW Control connection"; m_controlSocket = m_controlChannel.nextPendingConnection(); connect(m_controlSocket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); updateConnectionState(); }
void Server::onNewConnection() { QTcpSocket* client_socket = server->nextPendingConnection(); connect(client_socket, SIGNAL(readyRead()), this, SLOT(readData())); connect(client_socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); connect(client_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); printReport(tr("%1: User connected").arg(client_socket->socketDescriptor())); }
void QHtmlService::onServerNewConnection() { while (mServer.hasPendingConnections()) { QTcpSocket * const socket = mServer.nextPendingConnection(); connect(socket, SIGNAL(readyRead()), SLOT(onHttpSocketReadyRead())); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); } }
void CTIServer::onDisconnectError() { if (this->m_waiting_for_start_tls) { this->m_waiting_for_start_tls = false; emit disconnectedBeforeStartTls(); } else { onSocketDisconnected(); } }
void ServiceDirectoryClient::onSocketConnected(qi::FutureSync<void> future, qi::Promise<void> promise) { if (future.hasError()) { qi::Future<void> fdc = onSocketDisconnected(future.error()); fdc.connect(&qi::Promise<void>::setError, promise, future.error()); return; } qi::Future<void> fut = _remoteObject.fetchMetaObject(); fut.connect(&ServiceDirectoryClient::onMetaObjectFetched, this, _1, promise); }
Asterisk::Asterisk(QObject *parent, QString host, quint16 port) : QObject(parent), host(host), port(port) { connect(&socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(&socket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); qDebug("Asterisk Manager initialized"); }
TEST_F(WebSocketMessagingStubFactoryTest, closedMessagingStubsAreRemoved) { WebSocketMessagingStubFactory factory; QWebSocket* websocket = new QWebSocket(); factory.addClient(webSocketClientAddress, websocket); QSharedPointer<joynr::IMessaging> messagingStub(factory.create(webSocketClientAddress)); QSharedPointer<joynr::WebSocketMessagingStub> wsMessagingStub(messagingStub.dynamicCast<joynr::WebSocketMessagingStub>()); QSignalSpy wsMessagingStubClosedSpy(wsMessagingStub.data(), SIGNAL(closed(joynr::system::QtAddress))); EXPECT_FALSE(messagingStub.isNull()); QTimer::singleShot(0, wsMessagingStub.data(), SLOT(onSocketDisconnected())); EXPECT_TRUE(wsMessagingStubClosedSpy.wait()); EXPECT_EQ(1, wsMessagingStubClosedSpy.count()); EXPECT_TRUE(factory.create(webSocketClientAddress).isNull()); }
void Client::setSocket(QTcpSocket *socket) { this->socket = socket; this->socket->setParent(this); socketIn.setDevice(socket); socketOut.setDevice(socket); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); connect(socket, SIGNAL(disconnected()), SIGNAL(socketDisconnected())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); initiateHandshake(); resetHeartbeatTimer(); }
// ----------------------------------------------------------------------------- bool NetworkDeviceController::open() { // set some reasonable default values QString address("192.168.1.100"); int portnum = 8090; // was an address specified? if (m_device.length()) { // if so, split it into ip address and port number QStringList ssplit = m_device.split(":", QString::SkipEmptyParts); if (ssplit.size() != 2) { Logger::err("NetworkDevice: invalid address format (addr:port)\n"); return false; } address = ssplit[0]; portnum = ssplit[1].toInt(); } Logger::info(tr("NetworkDevice: creating network device %1 port %2\n") .arg(address).arg(portnum)); // attempt to create and connect to the network socket m_sock = new QTcpSocket(); connect(m_sock, SIGNAL(readyRead()), this, SLOT(onSocketReadyRead())); connect(m_sock, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); connect(m_sock, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); // attempt to connect to the specified address:port m_sock->connectToHost(address, portnum); if (!m_sock->waitForConnected(3000)) { emit connectionStatusChanged(QString("Connection failed"), false); Logger::warn("NetworkDevice: connection timed out\n"); return false; } emit connectionStatusChanged(QString("Connected to ") + m_device, true); Logger::info(tr("NetworkDevice: connected to ") + m_device + "\n"); emit flightStateChanged(FCS_STATE_GROUNDED); startup(); return true; }
void ServiceDirectoryClient::onMetaObjectFetched(qi::Future<void> future, qi::Promise<void> promise) { if (future.hasError()) { qi::Future<void> fdc = onSocketDisconnected(future.error()); fdc.connect(&qi::Promise<void>::setError, promise, future.error()); return; } boost::function<void (unsigned int, std::string)> f; f = boost::bind<void>(&ServiceDirectoryClient::onServiceAdded, this, _1, _2); qi::Future<SignalLink> fut1 = _object.connect("serviceAdded", f); f = boost::bind<void>(&ServiceDirectoryClient::onServiceRemoved, this, _1, _2); qi::Future<SignalLink> fut2 = _object.connect("serviceRemoved", f); fut1.connect(&ServiceDirectoryClient::onSDEventConnected, this, _1, promise, true); fut2.connect(&ServiceDirectoryClient::onSDEventConnected, this, _1, promise, false); }
bool QWebProcessor::newConnection(qint16 port, qintptr socketDescriptor) { qDebug()<<"QWebProcessor->newConnection()"<<socketDescriptor<<QTime::currentTime().toString(); if (socket) { QTcpSocket *sock = new QTcpSocket(); sock->setSocketDescriptor(socketDescriptor); sock->close(); sock->deleteLater(); return true; }else { this->port = port; socket = new QTcpSocket(); connect(socket, SIGNAL(readyRead()), this, SLOT(socketRead())); connect(socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); socket->setSocketDescriptor(socketDescriptor); return true; } }
DefaultConnection::DefaultConnection(IConnectionPlugin *APlugin, QObject *AParent) : QObject(AParent) { FPlugin = APlugin; FSrvQueryId = START_QUERY_ID; connect(&FDns, SIGNAL(resultsReady(int, const QJDns::Response &)),SLOT(onDnsResultsReady(int, const QJDns::Response &))); connect(&FDns, SIGNAL(error(int, QJDns::Error)),SLOT(onDnsError(int, QJDns::Error))); connect(&FDns, SIGNAL(shutdownFinished()),SLOT(onDnsShutdownFinished())); FSocket.setProtocol(QSsl::AnyProtocol); connect(&FSocket, SIGNAL(connected()), SLOT(onSocketConnected())); connect(&FSocket, SIGNAL(encrypted()), SLOT(onSocketEncrypted())); connect(&FSocket, SIGNAL(readyRead()), SLOT(onSocketReadyRead())); connect(&FSocket, SIGNAL(modeChanged(QSslSocket::SslMode)), SIGNAL(modeChanged(QSslSocket::SslMode))); connect(&FSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(onSocketError(QAbstractSocket::SocketError))); connect(&FSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(onSocketSSLErrors(const QList<QSslError> &))); connect(&FSocket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); FConnectTimer.setSingleShot(true); FConnectTimer.setInterval(CONNECT_TIMEOUT); connect(&FConnectTimer,SIGNAL(timeout()),SLOT(onConnectTimerTimeout())); }
qi::FutureSync<void> ServiceDirectoryClient::close() { return onSocketDisconnected("User closed the connection"); }