diff --git a/src/kernel/handler.cpp b/src/kernel/handler.cpp index 32ce270..676615f 100644 --- a/src/kernel/handler.cpp +++ b/src/kernel/handler.cpp @@ -5,8 +5,8 @@ Handler::Handler() using namespace std::placeholders; handlers = { - {"createSession", std::bind(&Handler::createSession, this, _1)}, - {"createSessionSuccess", std::bind(&Handler::createSessionSuccessMethod, this, _1)} + {"checkPeer", std::bind(&Handler::createSession, this, _1)}, + {"checkPeerSuccess", std::bind(&Handler::checkPeerSuccessMethod, this, _1)} }; network = new Network(); connect(network, &Network::json_received, this, &Handler::handle); @@ -23,12 +23,12 @@ void Handler::createSession(QJsonObject jsonReceived) { QJsonObject jsonSend; jsonSend["peerID"] = my_ipv6; - jsonSend["action"] = "createSessionSuccess"; + jsonSend["action"] = "checkPeerSuccess"; QString peerReceiver = jsonReceived["peerID"].toString(); network->sendDatagram(jsonSend, peerReceiver); } void Handler::createSessionSuccessMethod(QJsonObject jsonReceived) { - emit createSessionSuccess(); + emit checkPeerSuccess(); } diff --git a/src/kernel/handler.hpp b/src/kernel/handler.hpp index 15f380c..a436845 100644 --- a/src/kernel/handler.hpp +++ b/src/kernel/handler.hpp @@ -12,12 +12,12 @@ class Handler : public QObject public: Handler(); signals: - void createSessionSuccess(); + void checkPeerSuccess(); private: Network *network; void createSession(QJsonObject jsonReceived); std::map> handlers; - void createSessionSuccessMethod(QJsonObject jsonReceived); + void checkPeerSuccessMethod(QJsonObject jsonReceived); private slots: void handle(QJsonObject jsonReceived); }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 01f1212..389ab1e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -10,7 +10,7 @@ MainWindow::MainWindow(QWidget *parent) : handler = new Handler(); timer = new QTimer(); connect(timer, SIGNAL(timeout()), this, SLOT(slotTimerAlarm())); - connect(handler, &Handler::createSessionSuccess, this, &MainWindow::peerReceiverConnected); + connect(handler, &Handler::checkPeerSuccessSuccess, this, &MainWindow::peerReceiverAvailable); ui->myIP->setText(my_ipv6); } @@ -25,7 +25,7 @@ void MainWindow::on_connectToPeer_clicked() ui->connectToPeer->setText("Ожидание..."); QJsonObject j; j["peerID"] = my_ipv6; - j["action"] = "createSession"; + j["action"] = "checkPeer"; QString s = ui->peerID->text(); network->sendDatagram(j, s); timer->start(10000); @@ -48,7 +48,7 @@ void MainWindow::slotTimerAlarm() } -void MainWindow::peerReceiverConnected() +void MainWindow::peerReceiverAvailable() { receive = true; int ret = QMessageBox::information(this,QObject::tr("Info"),tr("Peer Available!")); diff --git a/src/mainwindow.h b/src/mainwindow.h index c032634..69905db 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -20,7 +20,7 @@ class MainWindow : public QMainWindow explicit MainWindow(QWidget *parent = 0); ~MainWindow(); public slots: - void peerReceiverConnected(); + void peerReceiverAvailable(); private slots: void on_connectToPeer_clicked(); void slotTimerAlarm();