RTAutomationManager::RTAutomationManager()
    : QMainWindow()
{
    ui.setupUi(this);

    layoutWindow();

    m_dialog = NULL;

    m_client = new ManagerClient();

    connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));

    connect(m_client, SIGNAL(clientConnected()), this, SLOT(clientConnected()));
    connect(m_client, SIGNAL(clientDisconnected()), this, SLOT(clientDisconnected()));
    connect(this, SIGNAL(clientRestart()), m_client, SLOT(clientRestart()));
    connect(this, SIGNAL(clientEnable(bool)), m_client, SLOT(clientEnable(bool)));

    m_client->resumeThread();

    restoreWindowState();
    initStatusBar();

    setWindowTitle(RTAutomationArgs::getAppName());
}
Exemple #2
0
Chat::Chat(QWidget *parent)
: QDialog(parent), ui(new Ui_Chat)
{
    //! [Construct UI]
    ui->setupUi(this);

#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
    setWindowState(Qt::WindowFullScreen);
#endif

    connect(ui->quitButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectClicked()));
    connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendClicked()));
    //! [Construct UI]

    //! [Create Chat Server]
    server = new ChatServer(this);
    connect(server, SIGNAL(clientConnected(QString)), this, SLOT(clientConnected(QString)));
    connect(server, SIGNAL(clientDisconnected(QString)), this, SLOT(clientDisconnected(QString)));
    connect(server, SIGNAL(messageReceived(QString,QString)),
            this, SLOT(showMessage(QString,QString)));
    connect(this, SIGNAL(sendMessage(QString)), server, SLOT(sendMessage(QString)));
    server->startServer();
    //! [Create Chat Server]

    //! [Get local device name]
    localName = QBluetoothLocalDevice().name();
    //! [Get local device name]
}
Exemple #3
0
Chat::Chat(QWidget *parent)
    : QDialog(parent),  currentAdapterIndex(0), ui(new Ui_Chat)
{
    ui->setupUi(this);

    connect(ui->quitButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectClicked()));
    connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendClicked()));

    localAdapters = QBluetoothLocalDevice::allDevices();
    if (localAdapters.count() < 2) {
        ui->localAdapterBox->setVisible(false);
    } else {
        //we ignore more than two adapters
        ui->localAdapterBox->setVisible(true);
        ui->firstAdapter->setText(tr("Default (%1)", "%1 = Bluetooth address").
                                  arg(localAdapters.at(0).address().toString()));
        ui->secondAdapter->setText(localAdapters.at(1).address().toString());
        ui->firstAdapter->setChecked(true);
        connect(ui->firstAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected()));
        connect(ui->secondAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected()));
        QBluetoothLocalDevice adapter(localAdapters.at(0).address());
        adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
    }

    server = new ChatServer(this);
    connect(server, SIGNAL(clientConnected(QString)), this, SLOT(clientConnected(QString)));
    connect(server, SIGNAL(clientDisconnected(QString)), this, SLOT(clientDisconnected(QString)));
    connect(server, SIGNAL(messageReceived(QString,QString)),
            this, SLOT(showMessage(QString,QString)));
    connect(this, SIGNAL(sendMessage(QString)), server, SLOT(sendMessage(QString)));
    server->startServer();

    localName = QBluetoothLocalDevice().name();
}
ConnectionSettingsPage::ConnectionSettingsPage(QWidget *parent)
    : SettingsPage(tr("IRC"), QString(), parent)
{
    ui.setupUi(this);
    initAutoWidgets();

    connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
    connect(Client::instance(), SIGNAL(disconnected()), this, SLOT(clientDisconnected()));

    setEnabled(false);
    if (Client::isConnected())
        clientConnected();
}
RemoteReceiver::RemoteReceiver(QObject *parent)
    : QObject(parent)
    , m_server(new IpcServer(this))
    , m_node(0)
    , m_connectionAcknowledged(false)
    , m_socket(0)
    , m_client(0)
{
    connect(m_server, SIGNAL(received(QString,QByteArray)), this, SLOT(handleCall(QString,QByteArray)));
    connect(m_server, SIGNAL(clientConnected(QTcpSocket*)), this, SLOT(onClientConnected(QTcpSocket*)));
    connect(m_server, SIGNAL(clientConnected(QHostAddress)), this, SIGNAL(clientConnected(QHostAddress)));
    connect(m_server, SIGNAL(clientDisconnected(QHostAddress)), this, SIGNAL(clientDisconnected(QHostAddress)));
}
Exemple #6
0
AliasesModel::AliasesModel(QObject *parent)
    : QAbstractItemModel(parent),
    _configChanged(false),
    _modelReady(false)
{
    // we need this signal for future connects to reset the data;
    connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
    connect(Client::instance(), SIGNAL(disconnected()), this, SLOT(clientDisconnected()));

    if (Client::isConnected())
        clientConnected();
    else
        emit modelReady(false);
}
Exemple #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_preferences(new Preferences),
    m_xmppClient(new QXmppClient(this)),
    m_loginWidget(new LoginWidget(this))
{
    ui->setupUi(this);
    initialize();

    ui->treeWidget->setClient(m_xmppClient);

    // xmpp client
    connect(m_xmppClient, SIGNAL(connected()),
            this, SLOT(clientConnected()));
    connect(m_xmppClient, SIGNAL(disconnected()),
            this, SLOT(clientDisconnected()) );
    connect(m_xmppClient, SIGNAL(error(QXmppClient::Error)),
            this, SLOT(clientError(QXmppClient::Error)));
    bool check = connect(m_xmppClient, SIGNAL(messageReceived(QXmppMessage)),
                    this, SLOT(messageReceived(QXmppMessage)));
    Q_ASSERT(check);


    // qApp
    connect( qApp, SIGNAL(lastWindowClosed()), this, SLOT(quit()) );
    // login
    connect(m_loginWidget, SIGNAL(login()), this, SLOT(login()));
    connect(m_loginWidget, SIGNAL(cancelLogin()), this, SLOT(cancelLogin()));
}
Exemple #8
0
void TcpServer::check_for_clients() {

  fd_set tmp_set;

  // Check if the Server has any new clients
  memcpy(&tmp_set, &m_server_set, sizeof(fd_set));
  safe_select(m_highest_socket+1, &tmp_set);

  if (FD_ISSET(m_socket_number, &tmp_set)) {
    // add a client
    ConnectionToClient* client = new ConnectionToClient();
    client->socket_len = sizeof(struct sockaddr_in);

    client->sock_fd = accept(m_socket_number, (sockaddr*)&client->addr, &client->socket_len);
    client->pending = 1;

    if (client->sock_fd < 0) {
      perror("accept");
      return;
    }

    if (client->sock_fd > m_highest_socket) {
      m_highest_socket = client->sock_fd;
    }

    printf("TcpServer: a client joined and was assigned fd: %d\n", client->sock_fd);
    m_clients[client->sock_fd] = client;
    FD_SET(client->sock_fd, &m_client_set);
    clientConnected(client);
  }
}
void WebSocketWorker::connectSocketSignals()
{
    QObject::connect(_socket, SIGNAL(connected()), this, SLOT(clientConnected()));
    QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
    QObject::connect(_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
    QObject::connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
}
Exemple #10
0
MainWindow::MainWindow()
    : QMainWindow(NULL) {
  log_ = new LogWindow(this);
  setCentralWidget(log_);
  setWindowIcon(QIcon(":/oyun.png"));
  
  QLOG_INFO() << "Server log console initialized.";

  tcp_server_ = new QTcpServer(this);
  if (!tcp_server_->listen()) {
    QLOG_FATAL() << "Unable to start the server!";
    QLOG_FATAL() << QString("Error message: %1").arg(tcp_server_->errorString());
    QLOG_FATAL() << "Server will not accept any clients.";
    
    return;
  }

  connect(tcp_server_, SIGNAL(newConnection()), this, SLOT(clientConnected()));
  QLOG_INFO() << QString("Server started, running on port %1").arg(tcp_server_->serverPort());

  bonjour_handler_ = new BonjourRegistrationHandler(this);
  bonjour_handler_->registerService(BonjourRecord(QString::fromUtf8("Oyun3D Server on %1").arg(QHostInfo::localHostName()),
                                                  QLatin1String("_oyun3d._tcp"), QString()),
                                    tcp_server_->serverPort());
}
Exemple #11
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    connector = new Server(this);



    myself.setName(QString("user ") + QString::number(qrand()));

    // connect(connector,SIGNAL(massageReceived(QByteArray)),this,SLOT(audioOutput(QByteArray))); \\

    connect(connector,SIGNAL(massageReceived(QByteArray)),this,SLOT(audioOutput(QByteArray))); \

    decoder = new AudioDecoder(this);
    recorder = new AudioRecorder(this);
    connect(recorder,SIGNAL(audioBufferder(QByteArray)), connector, SLOT(sendMessage(QByteArray)));

    ui->message_output->setReadOnly(true);
    ui->text_log->setReadOnly(true);


    QString host_rand = QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255) + QString(".") +
            QString::number(rand() * 255);
    // QHostAddress host = QHostAddress(host_rand);
    // QHostAddress host =  QHostAddress::LocalHost ;;
    QHostAddress host =  QHostAddress::Broadcast;
    connector->setPort(qrand());
    connector->setHostAdress(host);
    connector->bindHostPort();

    // connector->joinMulticastGroup(host);

    client_tcp = new ClientTcp(this);
    server_tcp = new ServerTCP(this);
    connect(client_tcp,SIGNAL(sendedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(client_tcp,SIGNAL(receivedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(client_tcp,SIGNAL(connected()),this,SLOT(serverFounded()));

    //connect(server_tcp,SIGNAL(),this,SLOT());
    connect(server_tcp,SIGNAL(sendedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(server_tcp,SIGNAL(receivedMessage(QByteArray)),this,SLOT(messageOutput(QByteArray)));
    connect(server_tcp,SIGNAL(newConnection()),this,SLOT(clientConnected()));

    QHostAddress hosta("127.15.10.12");

    quint16 port = 135665;
    client_tcp->setHostAdress(hosta);
    client_tcp->setPort(port);

    server_tcp->setHostAdress(hosta);
    server_tcp->setPort(port);
    //    connecor->ho



}
//! [clientConnected]
void TennisServer::clientConnected()
{
    qDebug() << Q_FUNC_INFO << "connect";

    QBluetoothSocket *socket = l2capServer->nextPendingConnection();
    if (!socket)
        return;

    if(clientSocket){
        qDebug() << Q_FUNC_INFO << "Closing socket!";
        delete socket;
        return;
    }

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

    stream = new QDataStream(socket);

    clientSocket = socket;    

    qDebug() << Q_FUNC_INFO << "started";

    emit clientConnected(clientSocket->peerName());
    lagTimer.start();
}
Exemple #13
0
RPCServer::RPCServer(int port){

  QSettings settings;
  bool ok = false;
  while(!ok){
    ok = listen(QHostAddress::Any, port);
    if(!ok && port < rpcMaxPort){
      /* Try going for higher ports until we can listen to one */
      qDebug("RPCServer: Failed to bind to port %d. Trying higher ports...",port);
      port++;
    }else{
      qDebug("RPCServer: Listening on port %d",port);
      settings.setValue("RPCServer/serverPort",port);
    }
  }  
  if(!ok){
    qDebug("RPCServer: All ports exhausted. Binding failed.");
    return;
  }
  attachSlot(QString("reconstructionStarted()"),this,SLOT(reconstructionStarted(quint64)));
  attachSlot(QString("reconstructionStopped()"),this,SLOT(reconstructionStopped(quint64)));
  attachSlot(QString("identificationKeySent(int)"),this,SLOT(receiveIdentificationKey(quint64,int)));
  QObject::connect(this,SIGNAL(clientConnected(quint64)),this,SLOT(onClientConnected(quint64)));
  QObject::connect(this,SIGNAL(clientDisconnected(quint64)),this,SLOT(onClientDisconnected(quint64)));
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //Definisemo tipove adrese servera, port servera, kao i username
    serverAddr = new QString;
    serverPort = new int;
    userName = new QString;

    //kao pocetni dijalog postavaljamo start sa parametrima gore definisanim
    startDialog start(serverAddr, serverPort, userName,this);
    start.setModal(true);
    start.exec();

    

    ui->setupUi(this);

	
    //Definisemo sta se desava kada kliknemo na dugme,tj koju akciju vrsimo,u ovom slucaju se konektujemo na server
	connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(on_pushButton_clicked()));
		

	socket = new QTcpSocket(this);
    connect(socket, SIGNAL(connected()), this, SLOT(clientConnected()));
    connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));

    socket->connectToHost(*serverAddr,*serverPort);
}
Exemple #15
0
void TCPClient::connected()
{
    isConnectedToHost = true;
    socketDescriptor = tcpSocket->socketDescriptor();
    if (DISPLAY_TCPCLIENT_DEBUG_MESSAGES)
        qDebug() << "[ Client" << socketDescriptor << "] Connected to " << hostAddress << ":" << hostPort;
    emit clientConnected(true);
}
Exemple #16
0
TcpServer::TcpServer(QObject *parent, DataRefProvider *refProvider) : QObject(parent), server(this), _refProvider(refProvider) {
    if(!server.listen(QHostAddress::Any, EXTPLANE_PORT)) {
        qDebug() << Q_FUNC_INFO << "Unable to listen on port " << EXTPLANE_PORT;
        return;
    }
    connect(&server, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    qDebug() <<  Q_FUNC_INFO << "Listening on port " << EXTPLANE_PORT;
}
void UBServer::newConnectionEvent() {
    if (m_socket)
        return;

    m_socket = m_server->nextPendingConnection();
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReadyEvent()));

    emit clientConnected(m_socket->localPort());
}
void LocalJsonServer::serverClientConnected()
{
  QLocalSocket* socket = m_server->nextPendingConnection();
  if (socket)
  {
    m_clientSockets << socket;
    connect(socket, &QLocalSocket::readyRead, this, &LocalJsonServer::clientReadyRead);
    emit clientConnected(socket);
  }
}
//! [clientConnected]
void ChatServer::clientConnected()
{
    QBluetoothSocket *socket = rfcommServer->nextPendingConnection();
    if (!socket)
        return;

    connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
    clientSockets.append(socket);
    emit clientConnected(socket->peerName());
}
Exemple #20
0
cTcpClient::cTcpClient(QObject* parent): QObject(parent)
{
    autoConnectGesetzt = false;
    aktMsg.len = 0;
    connectTimer = new QTimer(parent);

    connect( &client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(clientError(QAbstractSocket::SocketError)));
    connect( &client, SIGNAL(readyRead()), this, SLOT(read()));
    connect( &client, SIGNAL(connected()), this, SLOT(clientConnected()));

}
void TennisServer::startServer()
{
    if (l2capServer)
        return;

    //! [Create the server]
    l2capServer = new QL2capServer(this);
    connect(l2capServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    l2capServer->listen();
    //! [Create the server]

    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);

    //! [Class ServiceClass must contain at least 1 entry]
    QBluetoothServiceInfo::Sequence classId;
//    classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
    classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
    //! [Class ServiceClass must contain at least 1 entry]


    //! [Service name, description and provider]
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Example Tennis Server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
                             tr("Example bluetooth tennis server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("Nokia, QtDF"));
    //! [Service name, description and provider]

    //! [Service UUID set]
    serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
    //! [Service UUID set]

    //! [Service Discoverability]
    serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
                             QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
    //! [Service Discoverability]


    //! [Protocol descriptor list]
    QBluetoothServiceInfo::Sequence protocolDescriptorList;
    QBluetoothServiceInfo::Sequence protocol;
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
             << QVariant::fromValue(quint16(l2capServer->serverPort()));
    protocolDescriptorList.append(QVariant::fromValue(protocol));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
                             protocolDescriptorList);
    //! [Protocol descriptor list]

    //! [Register service]
    serviceInfo.registerService();
    //! [Register service]

}
void CreateGameDialog::create(){
    if(Connection::getInstance().createServer()){
        ui->infoLabel->setText(
            QString("Server created at\n").append(
            Connection::getInstance().getAddress().append(":").append(
            Connection::getInstance().getPort())));
        ui->statusLabel->setText("Waiting for client...");
		connect(  &Connection::getInstance(), SIGNAL(clientConnected()), this, SLOT(created()) );
    } else {
        ui->infoLabel->setText("Cannot create server!");
    }
}
Exemple #23
0
void main(void)
{
	/* Configure the oscillator for the device */
	ConfigureOscillator();



	/* Initialize I/O and Peripherals for application */
	 InitApp();

	W5200_nRESET = 0;
	__delay_us(5);
	W5200_nRESET = 1;
	__delay_ms(50);
	__delay_ms(50);
	__delay_ms(50);
	__delay_ms(50);
	
	/* Initialize application settings */
	InitSettings();
	
	/* Initialize TCP server */
	initServer(&macAddress, &gateway, &netmask);
	startServer(&localEndpoint);

        LED = 1;

    while(1)
    {
		if(clientConnected())
		{
			if(dataAvailable())
			{
				uint16_t length = getReceivedLength();
				if(length > MAX_BUFFER)
				{
					// Limit maximum buffer size to avoid ram saturation due to packet flooding, a normal communication is shorter anyway
					length = MAX_BUFFER;
				}
				
				uint8_t buffer[MAX_BUFFER];
				getReceivedData(buffer, length);
				
				parseCommand(buffer[0], buffer, length);
				
				stopServer();
				startServer(&localEndpoint);
			}
			checkClientDisconnection();
		}		
    }

}
Exemple #24
0
void TCPClient::connectToHost(QString ip, qint32 port)
{
    if (isConnectedToHost) {
        emit errorWarning(tr("Trying to connect while already connected."));
        emit clientConnected(false);
    }
    hostAddress = ip;
    hostPort = port;
    declareAndConnectSockets();
    tcpSocket->connectToHost(ip, port);
    connect(tcpSocket, SIGNAL(connected()), this, SLOT(connected()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
}
Exemple #25
0
bool GameServer::waitForClientConnection()
{
	/*
	while(::WaitForSingleObject(fEvtCLientConnected, 200) != WAIT_OBJECT_0)
	{
		if(fStopRequested)
			return false;
	}
	*/
	while(!fConnectionDispatcher->isClientConnected());
	clientConnected(fConnectionDispatcher->getConnectedClientSocket());
	return true;
}
Exemple #26
0
void ChatServer::startServer(const QBluetoothAddress& localAdapter)
{
    if (rfcommServer)
        return;

    rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
    connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    bool result = rfcommServer->listen(localAdapter);
    if (!result) {
        qWarning() << "Cannot bind chat server to" << localAdapter.toString();
        return;
    }

    //serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);

    QBluetoothServiceInfo::Sequence classId;

    classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
    serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,
                             classId);

    classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid)));

    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
    serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId);

    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
                             tr("Example bluetooth chat server"));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("qt-project.org"));

    serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));

    QBluetoothServiceInfo::Sequence publicBrowse;
    publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
    serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
                             publicBrowse);

    QBluetoothServiceInfo::Sequence protocolDescriptorList;
    QBluetoothServiceInfo::Sequence protocol;
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
    protocolDescriptorList.append(QVariant::fromValue(protocol));
    protocol.clear();
    protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
             << QVariant::fromValue(quint8(rfcommServer->serverPort()));
    protocolDescriptorList.append(QVariant::fromValue(protocol));
    serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
                             protocolDescriptorList);

    serviceInfo.registerService(localAdapter);
}
int CommunicationController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTcpServer::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: messageReceived((*reinterpret_cast< uint(*)>(_a[1])),(*reinterpret_cast< std::string(*)>(_a[2]))); break;
        case 1: clientConnected((*reinterpret_cast< uint(*)>(_a[1]))); break;
        case 2: clientDisconnected((*reinterpret_cast< uint(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Exemple #28
0
Client::Client(QObject *parent) :
    QObject(parent),
    m_client( new QXmppClient(this) )
{
    m_clientAddr = localHost();

    connect(m_client, SIGNAL(connected()), this,
            SLOT(clientConnected()) );
    connect(m_client, SIGNAL(disconnected()), this,
            SLOT(clientDisconnected()) );

    connect(m_client, SIGNAL(error(QXmppClient::Error)), this,
            SLOT(error(QXmppClient::Error)) );
    connect(m_client, SIGNAL(messageReceived(QXmppMessage)), this,
            SLOT(messageReceived(QXmppMessage)) );
}
Exemple #29
0
void ScreenProvider::incomingConnection(qintptr handle) {

    if(!streaming_) {

        streaming_ = true;
        emit clientConnected();

        watcher_ = new QFutureWatcher<void>();
        connect(watcher_, SIGNAL(finished()), this, SLOT(handleEndedStream()));
        future2_ = QtConcurrent::run(streamLoop,
                                     handle,
                                     std::ref(queue_),
                                     std::ref(streaming_));
        watcher_->setFuture(future2_);
    }
}
Exemple #30
0
void PingPong::startServer()
{
    setMessage(QStringLiteral("Starting the server"));
    //! [Starting the server]
    m_serverInfo = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
    connect(m_serverInfo, SIGNAL(newConnection()), this, SLOT(clientConnected()));
    connect(m_serverInfo, SIGNAL(error(QBluetoothServer::Error)),
            this, SLOT(serverError(QBluetoothServer::Error)));
    const QBluetoothUuid uuid(serviceUuid);

    m_serverInfo->listen(uuid, QStringLiteral("PingPong server"));
    //! [Starting the server]
    setMessage(QStringLiteral("Server started, waiting for the client. You are the left player."));
    // m_role is set to 1 if it is a server
    m_role = 1;
    Q_EMIT roleChanged();
}