mirror of
https://github.com/ChronosX88/Influence-cjdns.git
synced 2024-11-12 19:01:00 +00:00
Now the basic part of the application works stably.
The way of obtaining IPv6 is changed. Also changed the logic of the timer and fixed a bug with multiple calling the slot peerReceiverConnected().
This commit is contained in:
parent
aac8567528
commit
7df934b392
@ -8,6 +8,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
network = new Network(false);
|
network = new Network(false);
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
|
connect(handler, &Handler::createSessionSuccess, this, &MainWindow::peerReceiverConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -18,19 +19,23 @@ MainWindow::~MainWindow()
|
|||||||
void MainWindow::on_connectToPeer_clicked()
|
void MainWindow::on_connectToPeer_clicked()
|
||||||
{
|
{
|
||||||
QJsonObject j;
|
QJsonObject j;
|
||||||
j["peerID"] = QHostAddress("fc8f:cc50:70b0:3731:d686:a75e:94f2:f44f").toString();
|
j["peerID"] = my_ipv6;
|
||||||
j["action"] = "createSession";
|
j["action"] = "createSession";
|
||||||
QString s = ui->peerID->text();
|
QString s = ui->peerID->text();
|
||||||
network->sendDatagram(j, s);
|
network->sendDatagram(j, s);
|
||||||
timer = new QTimer();
|
timer = new QTimer();
|
||||||
connect(handler, &Handler::createSessionSuccess, this, &MainWindow::peerReceiverConnected);
|
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(slotTimerAlarm()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(slotTimerAlarm()));
|
||||||
timer->start(10000);
|
timer->start(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slotTimerAlarm()
|
void MainWindow::slotTimerAlarm()
|
||||||
{
|
{
|
||||||
if(!receive)
|
if(receive)
|
||||||
|
{
|
||||||
|
timer->stop();
|
||||||
|
receive = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int ret = QMessageBox::critical(this,QObject::tr("Error"),tr("Timeout Error"));
|
int ret = QMessageBox::critical(this,QObject::tr("Error"),tr("Timeout Error"));
|
||||||
timer->stop();
|
timer->stop();
|
||||||
@ -42,5 +47,5 @@ void MainWindow::slotTimerAlarm()
|
|||||||
void MainWindow::peerReceiverConnected()
|
void MainWindow::peerReceiverConnected()
|
||||||
{
|
{
|
||||||
receive = true;
|
receive = true;
|
||||||
int ret = QMessageBox::information(this,QObject::tr("Info"),tr("Peer available!"));
|
int ret = QMessageBox::information(this,QObject::tr("Info"),tr("Peer Available!"));
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,5 @@ class MainWindow : public QMainWindow
|
|||||||
Handler *handler;
|
Handler *handler;
|
||||||
|
|
||||||
bool receive;
|
bool receive;
|
||||||
|
const QString my_ipv6 = Network::local_ipv6();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user