void ClientApplication::start() {
	if (!parseCommandLine()) {
		QMessageBox::critical(NULL, applicationName(), trUtf8("Error in the command line arguments. Arguments:\n--host <h>\tConnect to the server on host <h>.\n--local\tRun client locally.\n--port <p>\tUse port <p> to connect to the server."));
		quit();
		return;
	}
	if (mode == mUnspecified) {
		ConnectDialog connectDialog;
		int code = connectDialog.exec();
		if (code == QDialog::Rejected) {
			quit();
			return;
		}
		if (connectDialog.local()) {
			mode = mLocal;
		}
		else {
			mode = mRemote;
			host = connectDialog.host();
			port = connectDialog.port();
		}
	}
	if (mode == mLocal) {
		theTrainer.reset(new Trainer());
		showMainWindow();
	}
	else {
		ProxyTrainer *trainer = new ProxyTrainer();
		theTrainer.reset(trainer);
		connect(trainer, SIGNAL(socketConnected()), SLOT(showMainWindow()));
		connect(trainer, SIGNAL(socketDisconnected()), SLOT(socketDisconnected()));
		connect(trainer, SIGNAL(socketError(QString)), SLOT(socketError(QString)));
		trainer->socketConnectToHost(host, port);
	}
}
Esempio n. 2
0
MTestThread::MTestThread(qintptr socketDescriptor) {
    m_socketDescriptor = socketDescriptor;
    m_netManager = new QLClientNetManager(0, this);
    connect(m_netManager,SIGNAL(newBinaryMessageReceived(QByteArray)),this,SLOT(newBinMsgFromClient(QByteArray)));
    connect(m_netManager,SIGNAL(socketDisconnected()),this,SLOT(socketDisconnected()));
    connect(m_netManager,SIGNAL(binaryMessageSent(quint32)),this,SLOT(binaryMessageSent(quint32)));

    m_err = 0;
    m_count = 0;

    m_packetN = 1000000;
}
Esempio n. 3
0
void ProtocolSocket::setSocket(QTcpSocket *socket)
{
    if (socket && socket->state() != QAbstractSocket::ConnectedState) {
        qWarning() << "BUG: ProtocolSocket::setSocket with unconnected socket";
        socket = 0;
    }

    if (socket == m_socket)
        return;

    bool wasConnected = isConnected();

    if (m_socket) {
        /* The existing socket is replaced, and all pending commands
         * are considered failed. This could be improved on. */
        QTcpSocket *oldSocket = m_socket;
        m_socket = 0;

        oldSocket->disconnect(this);
        // XXX can this be avoided if none are sent yet?
        abortCommands();
        oldSocket->abort();
        oldSocket->deleteLater();
    }

    m_socket = socket;

    if (socket) {
        socket->setParent(this);
        connect(socket, SIGNAL(readyRead()), this, SLOT(read()));
        // QueuedConnection used to make sure socket states are updated first
        connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()),
                Qt::QueuedConnection);
        connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(socketDisconnected()), Qt::QueuedConnection);

        if (!wasConnected) {
            m_connectedTime.restart();
            emit connected();
        }

        flushCommands();
        read();
    } else {
        emit disconnected();
    }

    emit socketChanged();
}
Esempio n. 4
0
SocketIOServer::SocketIOServer(QString name, int port)
{
    _server = new QIOServer(0);
    _server->moveToThread(&_backgroundThread);

    connect(_server, SIGNAL(newConnection()), this, SLOT(processNewConnection()));
    connect(_server, SIGNAL(socketDisconnected()), this, SLOT(socketDisconnected()));
    connect(_server, SIGNAL(newMessage(QString)), this, SLOT(processMessage(QString)));

    _backgroundThread.start();

    QMetaObject::invokeMethod(_server, "listen", Q_ARG(quint16, port));
    QMetaObject::invokeMethod(_server, "start");

}
Esempio n. 5
0
/** Connect to the splicer
 *
 *
 * @return
 *
 * History:
 * - 2010/08/03: STEELJ  - Initial Version.
  */
bool CAdChannel::connectSplicer()
{
  if (!m_socket)
  {
    m_socket = new QTcpSocket(this);
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(readData()));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
  }
  if (m_socket->state() != QAbstractSocket::UnconnectedState)
  {
    m_channelLogger->log(CLogLine::Error, "The TCP socket is already connected!");
    return false;
  }
  if (m_channelConfig.getSplicerAddress().isEmpty())
  {
    m_channelLogger->log(CLogLine::Error, "There is no splicer address defined");
    return false;
  }
  if (m_currentState != CAdState::StateNone)
  {
    m_channelLogger->log(CLogLine::Warning, QString("Trying to connect, but we are in a wrong splice state (%1)").arg(CAdState::toString(m_currentState)));
    changeState(CAdState::StateNone);
  }
  m_channelLogger->log(CLogLine::Info, QString("connecting to %1").arg(m_channelConfig.getSplicerAddress()));
  m_socket->connectToHost(m_channelConfig.getSplicerAddress(), s_Scte30Port);
  if (!m_socket->waitForConnected(3000))
  {
    m_channelLogger->log(CLogLine::Error, QString("Failed to connect to splicer on address %1 because %2").arg(m_channelConfig.getSplicerAddress(), m_socket->errorString()));
    return false;
  }
  changeState(CAdState::StateInit);
  return true;
}
Esempio n. 6
0
void PMaildServerBase::timeout() {
	if (status == CLOSING) {
		socketDisconnected();
	} else {
		close();
	}
}
Esempio n. 7
0
tlen::tlen( QObject* parent ): QObject( parent ) {
	state = tlen::Disconnected;

	hostname = "s1.tlen.pl";
	hostport = 443;
	Secure = false;
	Reconnect = false;

	Status= tlen::unavailable;
	Descr="";

	tmpDoc=new QDomDocument;

	socket=new QTcpSocket();
	ping=new QTimer();

	connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
	connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
	connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));

	connect(this, SIGNAL(tlenLoggedIn()), this, SLOT(writeStatus()));
	connect(this, SIGNAL(statusUpdate()), this, SLOT(writeStatus()));

	connect(this, SIGNAL(eventReceived(QDomNode)), this, SLOT(event(QDomNode)));

	connect(ping, SIGNAL(timeout()), this, SLOT(sendPing()));
	srand(time(NULL));
}
Esempio n. 8
0
//! [startClient]
void RfCommClient::startClient(const QBluetoothServiceInfo &remoteService)
{
    qDebug() << __PRETTY_FUNCTION__ << ">>";
    serviceInfo = remoteService;

    // make sure preconditions are met
    if (!powerOn() || socket) {
        qDebug() << __PRETTY_FUNCTION__ << "<< power not on or socket already exists!";
        return;
    }

    // Connect to service
    if (state == listening)
        state = pendingConnections;
    socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
    qDebug() << "Create socket";
    socket->connectToService(remoteService);
    qDebug() << "ConnecttoService done";

    connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
    connect(socket, SIGNAL(connected()), this, SLOT(connected()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(error(QBluetoothSocket::SocketError)));

    qDebug() << __PRETTY_FUNCTION__ << "<<";
}
Esempio n. 9
0
IndiClient::IndiClient(const int &attempts) : mPort(indi::PORT), mAttempts(attempts), mAttempt(1)
{
    connect(&mQTcpSocket, SIGNAL(connected()), SLOT(socketConnected()));
    connect(&mQTcpSocket, SIGNAL(disconnected()), SLOT(socketDisconnected()));
    connect(&mQTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));
    connect(&mQTcpSocket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
}
Esempio n. 10
0
void AdminWindow::showAdmin(ConnectionSettings *connection)
{
    // clear ui
    ui->usersList->clear();
    ui->usersList->addItem(tr("Updating..."));
    ui->usersList->setFocus(Qt::OtherFocusReason);

    // establish connection
    m_server = QSharedPointer<Server>(new Server(*connection));
    m_connector = QSharedPointer<Connector>(new Connector(m_server));

    bool success;
    success = connect(m_connector.data(), SIGNAL(failure(Connector::FailureReason)), this, SLOT(connectionFailure(Connector::FailureReason)), Qt::QueuedConnection);
    Q_ASSERT(success);
    success = connect(m_connector.data(), SIGNAL(success()), this, SLOT(connected()));
    Q_ASSERT(success);
    success = connect(m_server.data(), SIGNAL(messageReceived(QSharedPointer<IncomingMessage>)), this, SLOT(processMessage(QSharedPointer<IncomingMessage>)));
    Q_ASSERT(success);
    success = connect(m_server.data(), SIGNAL(socketDisconnected()), this, SLOT(connectionEnded()));
    Q_ASSERT(success);

    m_connector.data()->go();

    // show modal
    this->exec();
}
Esempio n. 11
0
QHttpConnection::QHttpConnection(QTcpSocket *socket, QObject *parent)
    : QObject(parent),
      m_socket(socket),
      m_parser(0),
      m_parserSettings(0),
      m_request(0),
      m_transmitLen(0),
      m_transmitPos(0)
{
    m_parser = (http_parser *)malloc(sizeof(http_parser));
    http_parser_init(m_parser, HTTP_REQUEST);

    m_parserSettings = new http_parser_settings();
    m_parserSettings->on_message_begin = MessageBegin;
    m_parserSettings->on_url = Url;
    m_parserSettings->on_header_field = HeaderField;
    m_parserSettings->on_header_value = HeaderValue;
    m_parserSettings->on_headers_complete = HeadersComplete;
    m_parserSettings->on_body = Body;
    m_parserSettings->on_message_complete = MessageComplete;

    m_parser->data = this;

    connect(socket, SIGNAL(readyRead()), this, SLOT(parseRequest()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(updateWriteCount(qint64)));
}
Esempio n. 12
0
/*!
  Connect to the configured port and host for the device and setting up
  the socket.
*/
void DeviceConnector::connect()
{
    if ( mSocket )  // already connected
        return;
    emit startingConnect();
    loginDone = false;
    mSocket = new QTcpSocket();
    QObject::connect( mSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(socketError()) );
    mSocket->connectToHost( QHostAddress( "10.10.10.20" ), 4245 );
    if ( !mSocket->waitForConnected() )
    {
        emit deviceConnMessage( tr( "Error connecting to device:" ) +
                mSocket->errorString() );
        delete mSocket;
        mSocket = 0;
        return;
    }
    QObject::connect( mSocket, SIGNAL(readyRead()),
            this, SLOT(socketReadyRead()) );
    QObject::connect( mSocket, SIGNAL(disconnected()),
            this, SLOT(socketDisconnected()) );
    emit deviceConnMessage( tr( "Device connected" ) );
    emit finishedConnect();
}
Esempio n. 13
0
bool MjpegClient::connectTo(const QString& host, int port, QString url, const QString& user, const QString& pass)
{
    if(url.isEmpty())
        url = "/";

    m_host = host;
    m_port = port > 0 ? port : 80;
    m_url = url;
    m_user = user;
    m_pass = pass;

    if(m_socket)
    {
        m_socket->abort();
        delete m_socket;
        m_socket = 0;
    }

    m_socket = new QTcpSocket(this);
    connect(m_socket, SIGNAL(readyRead()),    this,   SLOT(dataReady()));
    connect(m_socket, SIGNAL(disconnected()), this,   SLOT(lostConnection()));
    connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(socketDisconnected()));
    connect(m_socket, SIGNAL(connected()),    this, SIGNAL(socketConnected()));
    connect(m_socket, SIGNAL(connected()),    this,   SLOT(connectionReady()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(lostConnection(QAbstractSocket::SocketError)));

    m_socket->connectToHost(host,port);
    m_socket->setReadBufferSize(1024 * 1024);

    return true;
}
Esempio n. 14
0
/**
 * @brief SocketThread::run
 */
void SocketThread::run()
{
    std::cout << tr("connect done in thread : 0x%1").arg(QString::number((intptr_t)QThread::currentThreadId(), 16)).toStdString() << std::endl;

    if( !(conn = mysql_init((MYSQL*)NULL))){
      printf("init fail\n");
      exit(1);
    }

    printf("mysql_init success.\n");

    if(!mysql_real_connect(conn, server, user, password, NULL, 3306, NULL, 0)){
      printf("connect error.\n");
      exit(1);
    }

    printf("mysql_real_connect success.\n");

    if(mysql_select_db(conn, database) != 0){
      mysql_close(conn);
      printf("select_db fail.\n");
      exit(1);
    }

	// Connecting the socket signals here to exec the slots in the new thread
	QObject::connect(socket, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString)));
	QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
	QObject::connect(socket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));
	QObject::connect(this, SIGNAL(finished()), this, SLOT(finished()), Qt::DirectConnection);

	// Launch the event loop to exec the slots
	exec();
}
Esempio n. 15
0
TSock::TSock(QTcpSocket *sock, QObject *parent) :
  QObject(parent),
  listenPort(0)
{

    if (sock == NULL)
        socket = new QTcpSocket;
    else
        socket = sock;

    connect(socket, SIGNAL(connected()),
            this, SLOT(socketConnected()));

    connect(socket, SIGNAL(disconnected()),
            this, SLOT(socketDisconnected()));

    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(socketError(QAbstractSocket::SocketError)));

    connect(socket, SIGNAL(readyRead()),
            this, SLOT(socketDataReady()));


    connect(&server, SIGNAL(newConnection()),
            this, SLOT(serverConnection()));
}
Esempio n. 16
0
BtLocalDevice::BtLocalDevice(QObject *parent) :
    QObject(parent), securityFlags(QBluetooth::NoSecurity)
{
    localDevice = new QBluetoothLocalDevice(this);
    connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)),
            this, SIGNAL(error(QBluetoothLocalDevice::Error)));
    connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
            this, SIGNAL(hostModeStateChanged()));
    connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)),
            this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
    connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)),
            this, SLOT(connected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)),
            this, SLOT(disconnected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)),
            this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString)));

    if (localDevice->isValid()) {
        deviceAgent = new QBluetoothDeviceDiscoveryAgent(this);
        connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
                this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
        connect(deviceAgent, SIGNAL(finished()),
                this, SLOT(discoveryFinished()));
        connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
                this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
        connect(deviceAgent, SIGNAL(canceled()),
                this, SLOT(discoveryCanceled()));

        serviceAgent = new QBluetoothServiceDiscoveryAgent(this);
        connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
                this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
        connect(serviceAgent, SIGNAL(finished()),
                this, SLOT(serviceDiscoveryFinished()));
        connect(serviceAgent, SIGNAL(canceled()),
                this, SLOT(serviceDiscoveryCanceled()));
        connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
                this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error)));

        socket = new QBluetoothSocket(SOCKET_PROTOCOL, this);
        connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)),
                this, SLOT(socketStateChanged(QBluetoothSocket::SocketState)));
        connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)),
                this, SLOT(socketError(QBluetoothSocket::SocketError)));
        connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
        connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
        setSecFlags(socket->preferredSecurityFlags());

        server = new QBluetoothServer(SOCKET_PROTOCOL, this);
        connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection()));
        connect(server, SIGNAL(error(QBluetoothServer::Error)),
                this, SLOT(serverError(QBluetoothServer::Error)));
    } else {
        deviceAgent = 0;
        serviceAgent = 0;
        socket = 0;
        server = 0;
    }
}
Esempio n. 17
0
void Peer::socketDisconnected()
{
    log(this) << QString::fromLatin1("Peer [%1] disconnected").arg(getAddressPort()) << endl;

    disconnect(socket, SIGNAL(disconnectedFromPeer()), this, SLOT(socketDisconnected()));

    setState(UnconnectedState);
}
Esempio n. 18
0
void RfcommClient::socketDisconnected()
{
    waiter->hide();
    connectAction->setVisible(true);

    disconnect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    logArea->append(tr("Disconnected from server."));
}
Esempio n. 19
0
void Client::addSocket(QtWebsocket::QWsSocket *socket)
{
    sockets << socket;

    connect(socket, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString)));
    connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    connect(socket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));
}
Esempio n. 20
0
void
Connection::doSetup()
{
    qDebug() << Q_FUNC_INFO << thread();
    /*
        New connections can be created from other thread contexts, such as
        when AudioEngine calls getIODevice.. - we need to ensure that connections
        and their associated sockets are running in the same thread as the servent.

        HINT: export QT_FATAL_WARNINGS=1 helps to catch these kind of errors.
     */
    if( QThread::currentThread() != m_servent->thread() )
    {
        // Connections should always be in the same thread as the servent.
        qDebug() << "Fixing thead affinity...";
        moveToThread( m_servent->thread() );
        qDebug() << Q_FUNC_INFO  << thread();
    }

    //stats timer calculates BW used by this connection
    m_statstimer = new QTimer;
    m_statstimer->moveToThread( this->thread() );
    m_statstimer->setInterval( 1000 );
    connect( m_statstimer, SIGNAL( timeout() ), SLOT( calcStats() ) );
    m_statstimer->start();
    m_statstimer_mark.start();

    m_sock->moveToThread( thread() );

    connect( m_sock.data(), SIGNAL( bytesWritten( qint64 ) ),
                              SLOT( bytesWritten( qint64 ) ), Qt::QueuedConnection );

    connect( m_sock.data(), SIGNAL( disconnected() ),
                              SLOT( socketDisconnected() ), Qt::QueuedConnection );

    connect( m_sock.data(), SIGNAL( error( QAbstractSocket::SocketError ) ),
                              SLOT( socketDisconnectedError( QAbstractSocket::SocketError ) ), Qt::QueuedConnection );

    connect( m_sock.data(), SIGNAL( readyRead() ),
                              SLOT( readyRead() ), Qt::QueuedConnection );

    // if connection not authed/setup fast enough, kill it:
    QTimer::singleShot( AUTH_TIMEOUT, this, SLOT( authCheckTimeout() ) );

    if( outbound() )
    {
        Q_ASSERT( !m_firstmsg.isNull() );
        sendMsg( m_firstmsg );
    }
    else
    {
        sendMsg( Msg::factory( PROTOVER, Msg::SETUP ) );
    }

    // call readyRead incase we missed the signal in between the servent disconnecting and us
    // connecting to the signal - won't do anything if there are no bytesAvailable anyway.
    readyRead();
}
Esempio n. 21
0
void WebSocketServer::processNewConnection()
{
    QtWebsocket::QWsSocket* clientSocket = server->nextPendingConnection();
    QObject::connect(clientSocket, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString)));
    QObject::connect(clientSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    QObject::connect(clientSocket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));
    clients << clientSocket;
    std::cout << tr("Client connected").toStdString() << std::endl;
}
Esempio n. 22
0
//! [onNewConnection]
void ChatServer::onNewConnection()
{
    QWebSocket *pSocket = m_pWebSocketServer->nextPendingConnection();

    connect(pSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(processMessage(QString)));
    connect(pSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));

    m_clients << pSocket;
}
Esempio n. 23
0
void ServerController::newConnection()
{
    m_socket = m_server->nextPendingConnection();

    qDebug() << "Server got new connection";

    connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
    connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
}
Esempio n. 24
0
void RfcommClient::disconnectSocket()
{
    connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    waiter->setText(tr("Disconnecting..."));
    waiter->setCancelEnabled(false);
    waiter->show();
    userEntry->setEnabled(false);
    socket->disconnect();
    disconnectAction->setVisible(false);
    sendAction->setVisible(false);
}
Esempio n. 25
0
//! [onNewConnection]
void EchoServer::onNewConnection()
{
	WebSocket *pSocket = m_pWebSocketServer->nextPendingConnection();

	connect(pSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(processMessage(QString)));
	connect(pSocket, SIGNAL(binaryMessageReceived(QByteArray)), this, SLOT(processBinaryMessage(QByteArray)));
	connect(pSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
	//connect(pSocket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));

	m_clients << pSocket;
}
Esempio n. 26
0
void Server::processNewConnection()
{
    client = server->nextPendingConnection();

    QObject::connect(client, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString)));
    QObject::connect(client, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));

    std::cout << tr("Client connected").toStdString() << std::endl;
    connected = true;
    emit state(true);
}
Esempio n. 27
0
void Server::processNewConnection()
{
	QtWebsocket::QWsSocket* clientSocket = server->nextPendingConnection();

	QObject::connect(clientSocket, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString)));
	QObject::connect(clientSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
	QObject::connect(clientSocket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));

	clients << clientSocket;

	qDebug() << tr("Client connected (%1)").arg(clientSocket->isEncrypted() ? "encrypted" : "not encrypted");
}
Esempio n. 28
0
void Client::init(MainWindow *parent)
{
    c_score = 0;
    c_maxscore = 0;
    c_ready = false;
    c_results = new QMap<QString, QuestionAnswer>;
    c_blocksize = 1;
    c_parent = parent;
    c_test_sent = false;
    c_passed = true;

    QObject::connect(c_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
}
//! [onNewConnection]
void SslEchoServer::onNewConnection()
{
    QWebSocket *pSocket = m_pWebSocketServer->nextPendingConnection();

    qDebug() << "Client connected:" << pSocket->peerName() << pSocket->origin();

    connect(pSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(processMessage(QString)));
    connect(pSocket, SIGNAL(binaryMessageReceived(QByteArray)), this, SLOT(processBinaryMessage(QByteArray)));
    connect(pSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    //connect(pSocket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64)));

    m_clients << pSocket;
}
Esempio n. 30
0
bool TCPSendRawNode::initialise()
{
	if( !NodeControlBase::initialise() )
	{
		return( false );
	}

	connect( &mSocket, SIGNAL(connected()), this, SLOT(socketConnected()) );
	connect( &mSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected() ) );
	connect( &mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)) );
	connect( &mSocket, SIGNAL(hostFound()), this, SLOT(socketHostFound()) );

	return( true );
}