GameState::GameState( const QString & host, quint16 port, const QString & userName, NetworkClient::TcpClient & tcpClient) : NetworkClient::BaseGameState(nullptr), m_host(host), m_port(port), m_userName(userName) { nc::LoginHandler * loginHandler = new nc::LoginHandler; // Special signals are connected manually for now. connect(loginHandler, SIGNAL(compressionThresholdChanged(int)), &tcpClient, SLOT(setCompressionThreshold(int))); connect(loginHandler, SIGNAL(loginFinished()), this, SLOT(onLoginFinished())); addMessageHandler(loginHandler); addMessageHandler(new nc::KeepAliveHandler); ChatHandler * chatHandler = new ChatHandler; connect(chatHandler, SIGNAL(chatMessageReceived(QString)), this, SIGNAL(chatMessageReceived(QString))); addMessageHandler(chatHandler); DisconnectHandler * disconnectHandler = new DisconnectHandler; connect(disconnectHandler, SIGNAL(disconnectedFromServer(QString)), this, SIGNAL(disconnectedFromServer(QString))); addMessageHandler(disconnectHandler); }
void MainWindow::on_connectButton_clicked() { if(m_connectionState == ConnectionState::Disconnected) { QString host = ui->hostLineEdit->text(); quint16 port = ui->portSpinBox->value(); QString name = ui->nameLineEdit->text(); m_tcpClient.reset(new nc::TcpClient); m_gameState.reset(new GameState(host, port, name, *m_tcpClient.get())); connect(m_tcpClient.get(), SIGNAL(messageRead(QByteArray)), m_gameState.get(), SLOT(onInboundMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(outboundMessage(QByteArray)), m_tcpClient.get(), SLOT(writeMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(chatMessageReceived(QString)), this, SLOT(onChatMessageReceived(QString))); connect(m_gameState.get(), SIGNAL(disconnectedFromServer(QString)), this, SLOT(onDisconnected(QString))); connect(this, SIGNAL(chatMessageSent(QString)), m_gameState.get(), SLOT(onChatMessageSent(QString))); connect(m_tcpClient.get(), SIGNAL(connected()), this, SLOT(onConnected())); connect(m_tcpClient.get(), SIGNAL(disconnected()), this, SLOT(onDisconnected())); connect(m_tcpClient.get(), SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); m_tcpClient->connectToHost(host, port); changeConnectionState(ConnectionState::Connecting); qDebug() << "Connecting."; appendHtml(QString("<b>Connecting to %1:%2.</b><br>").arg(host).arg(port)); } else { m_tcpClient->disconnectFromHost(); } }
/*! Disconnected from the server. */ void BluetoothClient::onDisconnected() { qDebug() << "BluetoothClient::onDisconnected():" << mSocket->state(); if (!mRetries) { emit disconnectedFromServer(); } }
DrawingPad::DrawingPad(QWidget *parent) : QWidget(parent) , m_canvas( 0 ) , m_listenButton( 0 ) , m_listenPortEdit( 0 ) , m_connectButton( 0 ) , m_connectAddressEdit( 0 ) , m_connectPortEdit( 0 ) , m_connected( false ) { m_canvas = new Canvas; QLayout *colorLayout = setupColorSelector(); QLayout *widthLayout = setupWidthSelector(); QVBoxLayout *settingLayout = new QVBoxLayout; settingLayout->addLayout( colorLayout ); settingLayout->addLayout( widthLayout ); settingLayout->addStretch(); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addLayout( settingLayout ); hlayout->addWidget( m_canvas ); QLayout *fileLayout = setupFileButtons(); QLayout *networkLayout1 = setupListenButtons(); QLayout *networkLayout2 = setupConnectButtons(); QVBoxLayout *buttonLayout = new QVBoxLayout; buttonLayout->setSpacing( 0 ); buttonLayout->addLayout( fileLayout ); buttonLayout->addLayout( networkLayout1 ); buttonLayout->addLayout( networkLayout2 ); QVBoxLayout *topLayout = new QVBoxLayout; topLayout->addLayout( hlayout ); topLayout->addLayout( buttonLayout ); setLayout( topLayout ); resize( 600, 500 ); m_canvas->setLineColor( Qt::black ); widthSelected( 2 ); connect( &m_listener, SIGNAL(newConnection(ServerSocket *)), this, SLOT(newConnection(ServerSocket *)) ); connect( &m_clientSocket, SIGNAL(connected()), this, SLOT(connectedToServer()) ); connect( &m_clientSocket, SIGNAL(received(QByteArray)), m_canvas, SLOT(addData(QByteArray)) ); connect( &m_clientSocket, SIGNAL(disconnected()), this, SLOT(disconnectedFromServer()) ); connect( m_canvas, SIGNAL(dataAdded(QByteArray)), &m_clientSocket, SLOT(send(QByteArray)) ); }
//Le constructeur NetworkInterface::NetworkInterface(ConfigurationData *configurationData): QObject() { //On crèe la socket socket=new Socket(); //On établit les connexion des évenement de socket à la classe. QObject::connect(socket,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this,SLOT(stateChangedAction(QAbstractSocket::SocketState))); QObject::connect(socket,SIGNAL(connected()),this,SIGNAL(connectedToServer())); QObject::connect(socket,SIGNAL(disconnected()),this,SIGNAL(disconnectedFromServer())); QObject::connect(socket,SIGNAL(receiveMessage(QByteArray*)),this,SLOT(receiveMessageAction(QByteArray*))); //On initialise la socket this->configurationData=configurationData; }
EthereumMiner::EthereumMiner(QObject *parent) : QObject(parent) { _ethereumProtocol = new EthereumProtocol(this); // When losing connection, handle this. connect(_ethereumProtocol->stratumClient(), SIGNAL(disconnectedFromServer()), this, SLOT(handleDisconnect())); // Once we login to the server, we want to login in right after that. connect(_ethereumProtocol->stratumClient(), SIGNAL(connectedToServer()), this, SLOT(login())); // Once we have logged in, query for work. connect(_ethereumProtocol, SIGNAL(eth_login(bool)), _ethereumProtocol, SLOT(eth_getWork())); // Evertime we receive a work package, work on it. connect(_ethereumProtocol, SIGNAL(eth_getWork(QString,QString,QString)), this, SLOT(processWorkPackage(QString,QString,QString))); setCurrentStep(Halted); }
Worker::Worker(INotifyContextAccess *notifyContextAccess) : mNotifyContextAccess(notifyContextAccess), mWorker(new ThreadWorker()) { connect(mWorker, SIGNAL(connectedToServer()), this, SLOT(onConnectedToServer()), Qt::QueuedConnection); connect(mWorker, SIGNAL(disconnectedFromServer()), this, SLOT(onDisconnectedFromServer())); connect(mWorker, SIGNAL(error()), this, SLOT(onError())); connect(mWorker, SIGNAL(logMessage(QString)), this, SIGNAL(logMessage(QString))); mWorker->moveToThread(&mThread); mThread.start(); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(quit())); }
int QBtSerialPortClient::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: disconnectedFromServer(); break; case 1: connectionResetByPeer(); break; case 2: connectedToServer(); break; case 3: dataSent(); break; case 4: dataReceived((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 5: error((*reinterpret_cast< QBtSerialPortClient::ErrorCode(*)>(_a[1]))); break; case 6: connect((*reinterpret_cast< const QBtDevice(*)>(_a[1])),(*reinterpret_cast< const QBtService(*)>(_a[2]))); break; case 7: disconnect(); break; case 8: sendData((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 9: sendData((*reinterpret_cast< const QByteArray(*)>(_a[1]))); break; default: ; } _id -= 10; } return _id; }
void FKClientComponent::startComponent(){ if(!component()){ FKClientInfrastructure* client=static_cast<FKClientInfrastructure*>(componentFactory()->newInstance()); connect(client,SIGNAL(waitingForRealmAnswerChanged()),SIGNAL(waitingForRealmAnswerChanged())); connect(client,SIGNAL(waitingForServerAnswerChanged()),SIGNAL(waitingForServerAnswerChanged())); connect(client,SIGNAL(connectedToRealm()),SIGNAL(clientConnectedToRealm())); connect(client,SIGNAL(disconnectedFromRealm()),SIGNAL(clientDisconnectedFromRealm())); connect(client,SIGNAL(loggedIn()),SIGNAL(clientLoggedIn())); connect(client,SIGNAL(connectedToServer()),SIGNAL(clientConnectedToServer())); connect(client,SIGNAL(disconnectedFromServer()),SIGNAL(clientDisconnectedFromServer())); connect(client,SIGNAL(loggedInServer()),SIGNAL(clientLoggedInServer())); connect(client,SIGNAL(messageRequested(QString)),SIGNAL(messageRequested(QString))); connect(client,SIGNAL(roomInstruction(FKInstructionObject)),SIGNAL(roomInstruction(FKInstructionObject))); QString dbPath(FKPathResolver::clientDatabasePath()); QDir(dbPath).mkpath("."); FKDataBase* db=new FKFSDB(client); db->setPath(dbPath); client->setDataBase(db); FKThreadedComponent::startComponent(client); emit messageRequested(QString(tr("Started"))); emit started(); } }
void DisconnectHandler::onInboundMessage(int serverState, QByteArray data) { nc::ServerState trueState = static_cast<nc::ServerState>(serverState); if(trueState != nc::ServerState::Play) { return; } nc::MessageBuffer buffer(data); nc::VarInt messageCode; buffer >> messageCode; if(messageCode.getValue() != 0x40) // disconnect { return; } QString disconnectMessage; buffer >> disconnectMessage; emit disconnectedFromServer(disconnectMessage); }
void MainWindow::readSettings() { QSettings settings; settings.beginGroup("MainWindow"); resize(settings.value("size", QSize(800, 600)).toSize()); move(settings.value("pos", QPoint(200, 200)).toPoint()); ui->mainToolBar->setVisible(settings.value("mainToolBar", true).toBool()); ui->statusBar->setVisible(settings.value("statusbar", true).toBool()); ui->actToggleStatusBar->setChecked(settings.value("statusbar", true).toBool()); settings.endGroup(); m_hw = new HWSettings; DCServer *server = new DCServer(); server->setHost("localhost"); server->setPort("4303"); m_hw->setServer(server); connect (server, SIGNAL(connectionClosed()), this, SLOT(disconnectedFromServer())); connect (server, SIGNAL(connectionEstablished()), this, SLOT(connectedToServer())); DCTrain *t1 = new DCTrain(); t1->setName(QString("Train 1")); t1->setProtocol(DCTrain::MM2); t1->setAddress(10); t1->setDecoderSteps(14); t1->setDecoderFunctions(4); m_hw->addTrain(t1); DCTrain *t2 = new DCTrain(); t2->setName(QString("Train 2")); t2->setProtocol(DCTrain::MM2); t2->setAddress(20); t2->setDecoderSteps(14); t2->setDecoderFunctions(4); m_hw->addTrain(t2); connect ( ui->actStartTrains, SIGNAL(triggered()), m_hw, SLOT(startTrains())); connect ( ui->actStopTrains, SIGNAL(triggered()), m_hw, SLOT(stopTrains())); DCActuator *a1 = new DCActuator(); a1->setName(QString("Switch 1")); a1->setProtocol(DCActuator::MAERKLIN); a1->setType(DCActuator::GA_SWITCH); a1->setAddress(1); m_hw->addActuator(a1); DCActuator *a2 = new DCActuator(); a2->setName(QString("Switch 2")); a2->setProtocol(DCActuator::MAERKLIN); a2->setType(DCActuator::GA_SWITCH); a2->setAddress(2); m_hw->addActuator(a2); DCActuator *a3 = new DCActuator(); a3->setName(QString("Switch 3")); a3->setProtocol(DCActuator::MAERKLIN); a3->setType(DCActuator::GA_SWITCH); a3->setAddress(3); m_hw->addActuator(a3); DCActuator *a4 = new DCActuator(); a4->setName(QString("Switch 4")); a4->setProtocol(DCActuator::MAERKLIN); a4->setType(DCActuator::GA_SWITCH); a4->setAddress(4); m_hw->addActuator(a4); DCActuator *a5 = new DCActuator(); a5->setName(QString("Signal 1i")); a5->setProtocol(DCActuator::MAERKLIN); a5->setType(DCActuator::GA_SIGNAL); a5->setAddress(9); m_hw->addActuator(a5); DCActuator *a6 = new DCActuator(); a6->setName(QString("Signal 1o")); a6->setProtocol(DCActuator::MAERKLIN); a6->setType(DCActuator::GA_SIGNAL); a6->setAddress(11); m_hw->addActuator(a6); DCActuator *a7 = new DCActuator(); a7->setName(QString("Signal 2i")); a7->setProtocol(DCActuator::MAERKLIN); a7->setType(DCActuator::GA_SIGNAL); a7->setAddress(7); m_hw->addActuator(a7); DCActuator *a8 = new DCActuator(); a8->setName(QString("Signal 2o")); a8->setProtocol(DCActuator::MAERKLIN); a8->setType(DCActuator::GA_SIGNAL); a8->setAddress(5); m_hw->addActuator(a8); DCSensor *s1 = new DCSensor(); s1->setName(QString("Sensor 1 inner")); s1->setAddress(1); m_hw->addSensor(s1); DCSensor *s2 = new DCSensor(); s2->setName(QString("Sensor 1 outer")); s2->setAddress(2); m_hw->addSensor(s2); DCSensor *s3 = new DCSensor(); s3->setName(QString("Sensor 2 inner")); s3->setAddress(3); m_hw->addSensor(s3); DCSensor *s4 = new DCSensor(); s4->setName(QString("Sensor 2 outer")); s4->setAddress(4); m_hw->addSensor(s4); m_controller->setHWSettings(m_hw); }
/** * @brief Constructor * * Sets the activitionstate to true * * @author Peter Grasch */ SimonControl::SimonControl(QWidget *parent) : QObject (parent) { setStatus(SimonControl::Disconnected); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connected()), this, SLOT(connectedToServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(disconnected()), this, SLOT(disconnectedFromServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connectionError(QString)), this, SLOT(slotConnectionError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemError(QString)), this, SLOT(slotSimondSystemError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationError(QString)), this, SLOT(slotSynchronisationError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionError(QString,QString)), this, SLOT(slotRecognitionError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationError(QString,QString)), this, SLOT(slotCompilationError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemWarning(QString)), this, SLOT(slotSimondSystemWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationWarning(QString)), this, SLOT(slotSynchronisationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionWarning(QString)), this, SLOT(slotRecognitionWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationWarning(QString)), this, SLOT(slotCompilationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(loggedIn()), this, SLOT(loggedIn())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognised(RecognitionResultList)), this, SLOT(wordRecognised(RecognitionResultList))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionStatusChanged(RecognitionControl::RecognitionStatus)), this, SLOT(recognitionStatusChanged(RecognitionControl::RecognitionStatus))); QObject::connect(ScenarioManager::getInstance(), SIGNAL(deactivatedScenarioListChanged()), this, SIGNAL(deactivatedScenarioListChanged())); QObject::connect(this, SIGNAL(deactivatedScenarioListChanged()), RecognitionControl::getInstance(), SLOT(sendDeactivatedScenarioList())); QObject::connect(ContextManager::instance(), SIGNAL(sampleGroupChanged(QStringList)), RecognitionControl::getInstance(), SLOT(sendDeactivatedSampleGroups(QStringList))); ContextManager::instance()->getSampleGroupCondition()->loadSampleGroupContext(); ActionManager::getInstance(); // initializing action manager SimonTTS::getInstance(); // initializing TTS system for dbus interface if (!ScenarioManager::getInstance()->init()) { KMessageBox::error(0, i18n("Could not initialize scenarios and shadow dictionary.")); if (!ScenarioManager::getInstance()->getCurrentScenario()) { kDebug() << "Aborting due to fatal error while loading scenarios"; exit(-1); // this is fatal } } connect(SoundServer::getInstance(), SIGNAL(error(QString)), this, SLOT(slotSoundError(QString))); }
void HMI_Client::onDisconnected() { deviceList->clear(); hmi->clearWishlist(); emit disconnectedFromServer(); }