added basic communication between FriendServer and its clients

This commit is contained in:
csoler 2021-10-30 15:50:28 +02:00
parent d948086b5e
commit ffa28000e3
8 changed files with 165 additions and 12 deletions

View file

@ -40,12 +40,28 @@ FriendServerControl::FriendServerControl(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
if(!rsFriendServer)
{
setEnabled(false);
return;
}
mConnectionCheckTimer = new QTimer;
// init values
torServerFriendsToRequest_SB->setValue(rsFriendServer->friendsToRequest());
torServerAddress_LE->setText(QString::fromStdString(rsFriendServer->friendsServerAddress().c_str()));
torServerPort_SB->setValue(rsFriendServer->friendsServerPort());
// connect slignals/slots
QObject::connect(friendServerOnOff_CB,SIGNAL(toggled(bool)),this,SLOT(onOnOffClick(bool)));
QObject::connect(mConnectionCheckTimer,SIGNAL(timeout()),this,SLOT(checkServerAddress()));
QObject::connect(torServerFriendsToRequest_SB,SIGNAL(valueChanged(int)),this,SLOT(onFriendsToRequestChanged(int)));
QObject::connect(torServerAddress_LE,SIGNAL(textChanged(const QString&)),this,SLOT(onOnionAddressEdit(const QString&)));
QObject::connect(mConnectionCheckTimer,SIGNAL(timeout()),this,SLOT(checkServerAddress()));
mCheckingServerMovie = new QMovie(":/images/loader/circleball-16.gif");
serverStatusCheckResult_LB->setMovie(mCheckingServerMovie);
@ -65,6 +81,21 @@ void FriendServerControl::onOnOffClick(bool b)
else
rsFriendServer->stopServer();
}
void FriendServerControl::onOnionPortEdit(int)
{
// Setup timer to auto-check the friend server address
mConnectionCheckTimer->setSingleShot(true);
mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time.
mConnectionCheckTimer->start();
if(mCheckingServerMovie->fileName() != QString(":/images/loader/circleball-16.gif" ))
{
mCheckingServerMovie->setFileName(":/images/loader/circleball-16.gif");
mCheckingServerMovie->start();
}
}
void FriendServerControl::onOnionAddressEdit(const QString&)
{

View file

@ -35,10 +35,11 @@ public:
protected slots:
void onOnOffClick(bool b);
void onOnionAddressEdit(const QString&);
void onOnionPortEdit(int);
void onNbFriendsToRequestsChanged(int n);
void checkServerAddress();
private:
void checkServerAddress();
void updateFriendServerStatusIcon(bool ok);
QTimer *mConnectionCheckTimer;

View file

@ -72,6 +72,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
@ -108,7 +111,7 @@
<number>65536</number>
</property>
<property name="value">
<number>1729</number>
<number>2017</number>
</property>
</widget>
</item>