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()); }
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] }
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(); }
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))); }
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())); }
void TcpServer::check_for_messages() { fd_set tmp_set; std::map<int, ConnectionToClient*>::iterator it; int len_read; ConnectionToClient* client; uint32_t buf; memcpy(&tmp_set, &m_client_set, sizeof(fd_set)); safe_select(m_highest_socket+1, &tmp_set); for (it = m_clients.begin(); it != m_clients.end(); ++it) { client = it->second; if (FD_ISSET(client->sock_fd, &tmp_set)) { len_read = recv(client->sock_fd, (void*)&buf, sizeof(buf), MSG_PEEK); if (len_read > 0) { handleMessageFromClient(client); } else if (len_read == 0) { printf("TcpServer: length 0 message received from a client."); clientDisconnected(client); FD_CLR(client->sock_fd, &m_client_set); m_clients.erase(it); } else { perror("TcpServer read message"); } } } }
void Server::recieveConnection() { if (is_init_connection) return; QTcpSocket *clientConnection = tcpServer->nextPendingConnection(); QString client_ip = clientConnection->peerAddress().toString(); quint32 client_ip_int = clientConnection->peerAddress().toIPv4Address(); emit write_message(tr("New connection from IP: %1").arg(client_ip)); connect(clientConnection, SIGNAL(disconnected()), clientConnection, SLOT(deleteLater())); if (client_ip_int == QHostAddress(remoteIPAddress).toIPv4Address() || is_config_mode) { if (remote_server_socket && clientConnection != remote_server_socket) { delete remote_server_socket; } remote_server_socket = clientConnection; connect(clientConnection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(clientConnection, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(clientConnection, SIGNAL(readyRead()), this, SLOT(recieveData())); connect(clientConnection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); } else { clientConnection->abort(); } }
bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event) { assert(m_setup); // assert that the setup exists if (event->getType() == EVENT_TYPE_MESSAGE) { NetworkString &data = event->data(); assert(data.size()); // message not empty uint8_t message_type; message_type = data.getUInt8(); Log::info("ServerLobbyRoomProtocol", "Message received with type %d.", message_type); switch(message_type) { case LE_CONNECTION_REQUESTED: connectionRequested(event); break; case LE_REQUEST_BEGIN: startSelection(event); break; case LE_KART_SELECTION: kartSelectionRequested(event); break; case LE_VOTE_MAJOR: playerMajorVote(event); break; case LE_VOTE_RACE_COUNT: playerRaceCountVote(event); break; case LE_VOTE_MINOR: playerMinorVote(event); break; case LE_VOTE_TRACK: playerTrackVote(event); break; case LE_VOTE_REVERSE: playerReversedVote(event); break; case LE_VOTE_LAPS: playerLapsVote(event); break; case LE_RACE_FINISHED_ACK: playerFinishedResult(event); break; } // switch } // if (event->getType() == EVENT_TYPE_MESSAGE) else if (event->getType() == EVENT_TYPE_DISCONNECTED) { clientDisconnected(event); } // if (event->getType() == EVENT_TYPE_DISCONNECTED) return true; } // notifyEventAsynchronous
//! [Connect to remote service] void Chat::connectClicked() { ui->connectButton->setEnabled(false); // scan for services const QBluetoothAddress adapter = localAdapters.isEmpty() ? QBluetoothAddress() : localAdapters.at(currentAdapterIndex).address(); RemoteSelector remoteSelector(adapter); remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid)); if (remoteSelector.exec() == QDialog::Accepted) { QBluetoothServiceInfo service = remoteSelector.service(); qDebug() << "Connecting to service 2" << service.serviceName() << "on" << service.device().name(); // Create client qDebug() << "Going to create client"; ChatClient *client = new ChatClient(this); qDebug() << "Connecting..."; connect(client, SIGNAL(messageReceived(QString,QString)), this, SLOT(showMessage(QString,QString))); connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(client, SIGNAL(connected(QString)), this, SLOT(connected(QString))); connect(this, SIGNAL(sendMessage(QString)), client, SLOT(sendMessage(QString))); qDebug() << "Start client"; client->startClient(service); clients.append(client); } ui->connectButton->setEnabled(true); }
Server::Server(QWidget *parent) : QDialog(parent), mTcpServer(0), mNetworkSession(0) { QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } mNetworkSession = new QNetworkSession(config, this); connect(mNetworkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); mNetworkSession->open(); } else { sessionOpened(); } mIPAddressMapper = new QSignalMapper; connect(mTcpServer, SIGNAL(newConnection()), this, SLOT(acceptClientConnection())); connect(mIPAddressMapper, SIGNAL(mapped(QString)), this, SIGNAL(clientDisconnected(QString))); }
void FlatBufferClient::disconnected() { Debug(_log, "Socket Closed"); _socket->deleteLater(); _hyperion->clear(_priority); emit clientDisconnected(); }
void Server::recieveConnection() { QTcpSocket *clientConnection = tcpServer->nextPendingConnection(); connect(clientConnection, SIGNAL(disconnected()), clientConnection, SLOT(deleteLater())); QString client_ip = clientConnection->peerAddress().toString(); quint32 client_ip_int = clientConnection->peerAddress().toIPv4Address(); emit write_message(tr("New connection from IP: %1").arg(client_ip)); if (sockets->contains(client_ip_int)) { QTcpSocket *oldClientConnection = (QTcpSocket*) sockets->value(client_ip_int); if (oldClientConnection && oldClientConnection->state() != QAbstractSocket::UnconnectedState) { oldClientConnection->disconnectFromHost(); } sockets->remove(client_ip_int); } sockets->insert(client_ip_int, clientConnection); connect(clientConnection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(clientConnection, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(clientConnection, SIGNAL(readyRead()), this, SLOT(recieveData())); connect(clientConnection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); }
void PingPong::clientConnected() { //! [Initiating server socket] if (!m_serverInfo->hasPendingConnections()) { setMessage("FAIL: expected pending server connection"); return; } socket = m_serverInfo->nextPendingConnection(); if (!socket) return; socket->setParent(this); 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))); //! [Initiating server socket] setMessage(QStringLiteral("Client connected.")); QByteArray size; size.setNum(m_boardWidth); size.append(' '); QByteArray size1; size1.setNum(m_boardHeight); size.append(size1); size.append(" \n"); socket->write(size.constData()); }
QTcpSocket *Server::getRemoteSocket() { if (remote_server_socket && remote_server_socket->state()==QAbstractSocket::ConnectedState && remote_server_socket->isWritable()) { return remote_server_socket; } if (remote_server_socket) delete remote_server_socket; is_init_connection = true; remote_server_socket = new QTcpSocket(); remote_server_socket->connectToHost(QHostAddress(remoteIPAddress), remote_port, QIODevice::ReadWrite); if (remote_server_socket->waitForConnected(5000)) { connect(remote_server_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(remote_server_socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(remote_server_socket, SIGNAL(readyRead()), this, SLOT(recieveData())); connect(remote_server_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); } else { emit error(tr("Connect error: %1").arg(remote_server_socket->errorString())); delete remote_server_socket; remote_server_socket = NULL; } is_init_connection = false; if (!remote_server_socket) { connectionTimer->start(); } else { connectionTimer->stop(); } return remote_server_socket; }
Task::Task(Connection* parent, bool) :QObject(parent) { init(); d->client = parent; connect(d->client, SIGNAL(disconnected()), SLOT(clientDisconnected())); }
Task::Task(Task *parent) :QObject(parent) { init(); d->client = parent->client(); connect(d->client, SIGNAL(disconnected()), SLOT(clientDisconnected())); }
void QuteMessenger::InitializeBluetooth() { // power on bluetooth QBtLocalDevice::askUserTurnOnBtPower(); const QBtUuid uid = QBtUuid(QBtConstants::SerialPort); // start rfcomm server rfcommServerServiceName = QString("Messenger Protocol "); rfcommServerServiceName += QBtLocalDevice::getLocalDeviceName(); rfcommServer = new QBtSerialPortServer(this); rfcommServer->startServer(uid, rfcommServerServiceName); connect(rfcommServer, SIGNAL(clientDisconnected()), this, SLOT(restartSerialPortServer())); connect(rfcommServer, SIGNAL(clientConnected(const QBtAddress &)), this, SLOT(createNewTab(const QBtAddress &))); //create an instance of BT device discoverer devDisc = new QBtDeviceDiscoverer(this); //service discoverer serviceDisc = new QBtServiceDiscoverer(this); }
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))); }
//! [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(); }
void IntProcServer::handleNewConnection() { if(clientConnection) return; clientConnection = nextPendingConnection(); connect(clientConnection, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(clientConnection, SIGNAL(readyRead()), this, SLOT(readData())); connect(clientConnection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(stateChanged(QAbstractSocket::SocketState))); }
void TCPClient::disconnected() { if (DISPLAY_TCPCLIENT_DEBUG_MESSAGES) qDebug() << "Client" << getSocketDescriptor() << "was disconnected from the server."; isConnectedToHost = false; hostAddress = ""; emit clientDisconnected(this, (tcpSocket->error() == QAbstractSocket::RemoteHostClosedError)); }
void TestServiceView::addInterface(QString interface) { TestInterface *testInterface = new TestInterface(mService, interface); connect(testInterface, SIGNAL(clientDisconnected()), this, SLOT(requestCompleted())); connect(testInterface, SIGNAL(returnValueDelivered()), this, SLOT(requestCompleted())); connect(this, SIGNAL(quit()), qApp, SLOT(quit())); mInterfaces.append(testInterface); qDebug() << "[QTH] [AutoTestServices] TestServiceView::addInterface:" << interface; }
void Server::clientProcessing() { clientSocket = tcpServer->nextPendingConnection(); sendMessageButton->setEnabled(true); messageLineEdit->setEnabled(true); connect(clientSocket, SIGNAL(readyRead()), this, SLOT(readingMessage())); connect(clientSocket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(clientSocket, SIGNAL(disconnected()), clientSocket, SLOT(deleteLater())); }
void ClientThread::disconnected() { qDebug() << socketDescriptor << " Client disconnected"; socket->deleteLater(); emit clientDisconnected(user); QTimer::singleShot(1, this, SLOT(quit())); }
void MxServer::newConnection() { auto client = mServer->nextPendingConnection(); if (client) { connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(client, SIGNAL(readyRead()), this, SLOT(readyRead())); printf("%s\n", "Client connected"); } }
void MainWindow::clientConnected() { QTcpSocket *client_connection = tcp_server_->nextPendingConnection(); QLOG_INFO() << QString("Client connected: %1:%2").arg(client_connection->peerAddress().toString()).arg(client_connection->peerPort()); connect(client_connection, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(client_connection, SIGNAL(readyRead()), this, SLOT(clientDataAvailable())); }
void MonServeur::newClientConnection() { QTcpSocket *newClient = nextPendingConnection(); qDebug() << "New Client "; _clients << newClient; connect(newClient,SIGNAL(readyRead()),this,SLOT(dataIncoming())); connect(newClient,SIGNAL(disconnected()),this,SLOT(clientDisconnected())); }
//SLOT : quand une nouvelle connexion est établie, ajoute un Client à la liste et le connecte void Server::nouvelleConnexion() { User nouveauClient(serveur->nextPendingConnection()) ; //Un client se connecte, on l'ajoute qDebug() << "Client connected : " << nouveauClient.sock->peerAddress(); connect(nouveauClient.sock, SIGNAL(readyRead()), this, SLOT(receiveMessage())); connect(nouveauClient.sock, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); nouveauClient.port=-1; clients << nouveauClient; }
void Server::acceptConnection() { clientSocket = tcpServer->nextPendingConnection(); emit throwNewConfig(); connectionLabel->setText("Вы можете играть"); okButton->setEnabled(true); connect(clientSocket, SIGNAL(readyRead()), this, SLOT(startRead())); connect(clientSocket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(clientSocket, SIGNAL(disconnected()), clientSocket, SLOT(deleteLater())); }
CntServiceProviderOld::CntServiceProviderOld(CntServices& aServices, QObject *parent): XQServiceProvider(QLatin1String("com.nokia.services.phonebookservices.Fetch"), parent), mServices(aServices), mCurrentRequestIndex(0) { CNT_ENTRY publishAll(); connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp())); CNT_EXIT }