Some bugs fixed and sockets keepalive enabled
This commit is contained in:
parent
30b920b9a1
commit
8751345575
3 changed files with 8 additions and 7 deletions
|
@ -34,7 +34,7 @@ AvahiTcpAnnouncer::AvahiTcpAnnouncer()
|
|||
|
||||
service = new DNSSD::PublicService(QHostInfo::localHostName(), serviceType, port);
|
||||
|
||||
mServer = new QTcpServer();
|
||||
mServer = new QTcpServer(this);
|
||||
connect(mServer,SIGNAL(newConnection()),this, SLOT(newConnection()));
|
||||
mServer->listen(QHostAddress::Any, port);
|
||||
|
||||
|
@ -45,6 +45,7 @@ void AvahiTcpAnnouncer::newConnection()
|
|||
qDebug() << "AvahiTcpAnnouncer newConnection";
|
||||
|
||||
QTcpSocket* socket = mServer->nextPendingConnection();
|
||||
socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);
|
||||
|
||||
connect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived()));
|
||||
|
||||
|
|
|
@ -71,10 +71,6 @@ void NetworkPackage::unserialize(QByteArray a, NetworkPackage* np)
|
|||
np->setVersion(-1);
|
||||
}
|
||||
|
||||
if (np->version() > CURRENT_PACKAGE_VERSION) {
|
||||
qDebug() << "Warning: package version " << np->version() << " greater than supported version " << CURRENT_PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
//QVariant -> Object
|
||||
//NetworkPackage np;
|
||||
//QJSon json(a);
|
||||
|
@ -82,6 +78,11 @@ void NetworkPackage::unserialize(QByteArray a, NetworkPackage* np)
|
|||
//np.mType = json["type"];
|
||||
//np.mBody = json["body"];
|
||||
QJson::QObjectHelper::qvariant2qobject(variant,np);
|
||||
|
||||
if (np->version() > CURRENT_PACKAGE_VERSION) {
|
||||
qDebug() << "Warning: package version " << np->version() << " greater than supported version " << CURRENT_PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NetworkPackage::createIdentityPackage(NetworkPackage* np)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QApplication>
|
||||
|
||||
ClipboardPackageInterface::ClipboardPackageInterface() {
|
||||
qDebug() << "ClipboardPackageInterface";
|
||||
clipboard = QApplication::clipboard();
|
||||
ignore_next_clipboard_change = false;
|
||||
connect(clipboard,SIGNAL(changed(QClipboard::Mode)),this,SLOT(clipboardChanged()));
|
||||
|
@ -37,7 +36,7 @@ void ClipboardPackageInterface::clipboardChanged()
|
|||
ignore_next_clipboard_change = false;
|
||||
return;
|
||||
}
|
||||
qDebug() << "ClipboardChanged";
|
||||
//qDebug() << "ClipboardChanged";
|
||||
NetworkPackage np(PACKAGE_TYPE_CLIPBOARD);
|
||||
np.set("content",clipboard->text());
|
||||
emit sendPackage(np);
|
||||
|
|
Loading…
Reference in a new issue