void exeCommand(char command[]) { if (command[0] != '/') { printf("Invalid format. Commands should start with `/\'\n"); return; } if (strcmp(command, "/help") == 0 || strcmp(command, "/?") == 0) { puts(Manual); return; } if (strcmp(command, "/clear") == 0) { system("clear"); return; } if (strcmp(command, "/refresh") == 0) { clientRefresh(); return; } if (strcmp(command, "/bid") == 0) { clientBid(); return; } if (strcmp(command, "/leave") == 0) { clientLeave(); return; } printf("Command not found.\n"); return; }
void MainWindow::setupSignalsSlots() { //signal-slot: //connect(_thread,SIGNAL(updateUI(QStringList)),this,SLOT(updateClients(QStringList)),Qt::QueuedConnection); qRegisterMetaType<QVector<Device*> >("QVector<Device*>"); connect(m_restoreAction, &QAction::triggered, this, [this](){ setMainWindowVisibility(isHidden() || windowState() == Qt::WindowMinimized || (qApp->applicationState() == Qt::ApplicationInactive)); }); connect(m_quitAction, &QAction::triggered, this, &MainWindow::close); connect(m_controlWifi,&QAction::triggered,this,&MainWindow::on_pushButton_clicked); connect(m_restartWifi,&QAction::triggered,this,[this](){ ui->pushButton->setText("Restaring..."); m_wifi->restartWifi(); ui->pushButton->setText("STOP"); }); connect(m_wthread,SIGNAL(clientAdd(QVector<Device *>)),this,SLOT(updateNewClients(QVector<Device*>)),Qt::QueuedConnection); connect(m_wthread,SIGNAL(clientLeave(QVector<Device *>)),this,SLOT(updateLeaveClients(QVector<Device*>)),Qt::QueuedConnection); connect(m_wthread,SIGNAL(clientUpdate(QVector<Device*>)),this,SLOT(updateDevicesList(QVector<Device*>)),Qt::QueuedConnection); }
void TerrainView::leaveEvent(QEvent *e) { emit clientLeave(e); }
void MainWindow::newClient() { if(connectedMode=="Tcp socket (QTcpServer)") { QTcpSocket *newClient = TcpServer.nextPendingConnection(); ui->statusBarApp->showMessage("New client connected: "+newClient->peerAddress().toString(),10000); //connect(newClient, SIGNAL(readyRead()), this, SLOT(dataincommingUI())); connect(newClient, SIGNAL(disconnected()), this, SLOT(clientLeave())); connect(newClient, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(newErrorTcp(QAbstractSocket::SocketError))); connect(newClient, SIGNAL(readyRead()), this, SLOT(newData())); tcpSocket << new tcpClientInfo; tcpSocket.last()->tcpSocket=newClient; tcpSocket.last()->isConnected=true; tcpSocket.last()->LastEditionMode=ui->comboBoxTypeTx->currentText(); QListWidgetItem *TempItem=new QListWidgetItem(QIcon(":/images/preferences-desktop-user.png"),QString::number(idConnection++)+": "+newClient->peerAddress().toString()); TempItem->setToolTip("ip: "+newClient->peerAddress().toString()+", port: "+QString::number(newClient->peerPort())); tcpSocket.last()->ItemInList=TempItem; ui->listWidgetClient->addItem(TempItem); //compression part tcpSocket.last()->compression=NULL; switch(ui->compressionType->currentIndex()) { case 2: tcpSocket.last()->compression=new ZlibCompressionTcpSocket(ui->compressionBufferSize->value(),9,ui->compressionByPacket->isChecked()); break; case 3: tcpSocket.last()->compression=new GzipCompressionTcpSocket(ui->compressionBufferSize->value(),9,ui->compressionByPacket->isChecked()); break; case 0: tcpSocket.last()->compression=new Lz4HcCompressionTcpSocket(); break; case 1: default: tcpSocket.last()->compression=new Lz4CompressionTcpSocket(); break; } } if(connectedMode==COMBOBOXTEXTLOCALSOCK) { QLocalSocket *newClient = LocalServer.nextPendingConnection(); ui->statusBarApp->showMessage("New client connected",10000); connect(newClient, SIGNAL(disconnected()), this, SLOT(clientLeave())); connect(newClient, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(newErrorLocal(QLocalSocket::LocalSocketError))); connect(newClient, SIGNAL(readyRead()), this, SLOT(newData())); localSocket << new localClientInfo; localSocket.last()->localSocket=newClient; localSocket.last()->isConnected=true; localSocket.last()->LastEditionMode=ui->comboBoxTypeTx->currentText(); localSocket.last()->ItemInList=new QListWidgetItem(QIcon(":/images/preferences-desktop-user.png"),QString::number(idConnection++)+": Local Client"); ui->listWidgetClient->addItem(localSocket.last()->ItemInList); //compression part localSocket.last()->compression=NULL; switch(ui->compressionType->currentIndex()) { case 2: localSocket.last()->compression=new ZlibCompressionTcpSocket(ui->compressionBufferSize->value(),9,ui->compressionByPacket->isChecked()); break; case 3: localSocket.last()->compression=new GzipCompressionTcpSocket(ui->compressionBufferSize->value(),9,ui->compressionByPacket->isChecked()); break; case 0: localSocket.last()->compression=new Lz4HcCompressionTcpSocket(); break; case 1: default: localSocket.last()->compression=new Lz4CompressionTcpSocket(); break; } } if(ui->listWidgetClient->count()==1) { ui->listWidgetClient->item(0)->setSelected(true); updateCurrentData(); } }