Example #1
0
void CmaClient::connectWireless()
{
    vita_device_t *vita;
    wireless_host_info_t host = {NULL, NULL, NULL, QCMA_REQUEST_PORT};
    typedef CmaClient CC;

    QTime now = QTime::currentTime();
    qsrand(now.msec());

    qDebug("Starting wireless_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());

    setActive(true);

    do {
        if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::cancelCallback, CC::deviceRegistered, CC::generatePin, CC::registrationComplete)) != NULL) {
            processNewConnection(vita);
        } else {
            Sleeper::msleep(2000);
            mutex.lock();
            if(in_progress) {
                sema.acquire();
            }
            mutex.unlock();;
        }
    } while(isActive());

    qDebug("Finishing wireless_thread");
    emit finished();
}
Example #2
0
NativeServerSocket::NativeServerSocket()
{
    server = new QTcpServer(this);
    daemon = NULL;

    connect(server, SIGNAL(newConnection()), this, SLOT(processNewConnection()));
}
Example #3
0
void CmaClient::connectUsb()
{
    vita_device_t *vita;

    qDebug("Starting usb_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());

    setActive(true);

    do {
        if((vita = VitaMTP_Get_First_USB_Vita()) !=NULL) {
            processNewConnection(vita);
        } else {
            //TODO: replace this with an event-driven setup
            Sleeper::msleep(2000);
            mutex.lock();
            if(in_progress) {
                sema.acquire();
            }
            mutex.unlock();
        }
    } while(isActive());

    qDebug("Finishing usb_thread");
    emit finished();
}
Example #4
0
WebSocketServer::WebSocketServer(int port, QtWebsocket::Protocol protocol)
{
    server = new QtWebsocket::QWsServer(this, protocol);
    if (! server->listen(QHostAddress::Any, port))
    {
        std::cout << tr("Error: Can't launch server").toStdString() << std::endl;
        std::cout << tr("QWsServer error : %1").arg(server->errorString()).toStdString() << std::endl;
    }
    else
    {
        std::cout << tr("WebSocket server is listening on port %1").arg(port).toStdString() << std::endl;
    }
    QObject::connect(server, SIGNAL(newConnection()), this, SLOT(processNewConnection()));
}
Example #5
0
ServerThreaded::ServerThreaded()
{
	int port = 1337;
	server = new QWsServer( this );
	if ( ! server->listen( QHostAddress::Any, port ) )
	{
		Log::display( "Error: Can't launch server" );
		Log::display( "QWsServer error : " + server->errorString() );
	}
	else
	{
		Log::display( "Server is listening port " + QString::number(port) );
	}
	connect( server, SIGNAL(newConnection()), this, SLOT(processNewConnection()) );
}
Example #6
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");

}
Example #7
0
/**
 * @brief ServerThreaded::init
 */
void ServerThreaded::init()
{
    int port = 8080; //dddd
    server = new QtWebsocket::QWsServer(this);
    if (! server->listen(QHostAddress::Any, port))
    {
        std::cout << QObject::tr("Error: Can't launch server").toStdString() << std::endl;
        std::cout << QObject::tr("QWsServer error : %1").arg(server->errorString()).toStdString() << std::endl;
    }
    else
    {
        std::cout << QObject::tr("Server is listening port %1").arg(port).toStdString() << std::endl;
    }
    QObject::connect(server, SIGNAL(newConnection()), this, SLOT(processNewConnection()));
}
Example #8
0
Server::Server(int port, QtWebsocket::Protocol protocol)
{
	if(protocol == QtWebsocket::Tcp)
		server = new QtWebsocket::QWsServer(this, protocol);
	else
	{
		QFile file("server-key.pem");
		if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
		{
			qDebug() << "can't open key server-key.pem";
			throw -1;
		}
		QSslKey key(&file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray("qtwebsocket-server-key"));
		file.close();

		QFile file2("server-crt.pem");
		if (!file2.open(QIODevice::ReadOnly | QIODevice::Text))
		{
			qDebug() << "cant load server certificate server-crt.pem";
			throw -2;
		}
		QSslCertificate localCert(&file2, QSsl::Pem);
		file2.close();

		QSslConfiguration sslConfiguration;
		sslConfiguration.setPrivateKey(key);
		sslConfiguration.setLocalCertificate(localCert);
		sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);

		QList<QSslCertificate> caCerts = QSslCertificate::fromPath("ca.pem");
		server = new QtWebsocket::QWsServer(this, protocol, sslConfiguration, caCerts);
	}
	if (! server->listen(QHostAddress::Any, port))
	{
		qDebug() << tr("Error: Can't launch server");
		qDebug() << tr("QWsServer error : %1").arg(server->errorString());
	}
	else
	{
		qDebug() << tr("Server is listening on port %1").arg(port);
	}
	QObject::connect(server, SIGNAL(newConnection()), this, SLOT(processNewConnection()));
}