From 0deb0370353e0388e7bb12d5c3742de41f4e40ca Mon Sep 17 00:00:00 2001 From: Zach H Date: Sun, 1 Oct 2023 15:30:54 -0400 Subject: [PATCH] Address connect errors in logs (#4882) --- servatrice/src/servatrice.cpp | 4 ++-- servatrice/src/serversocketinterface.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 4e16ff24..fff5a4a0 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -85,7 +85,7 @@ void Servatrice_GameServer::incomingConnection(qintptr socketDescriptor) Servatrice_ConnectionPool *pool = findLeastUsedConnectionPool(); auto ssi = new TcpServerSocketInterface(server, pool->getDatabaseInterface()); - connect(ssi, SIGNAL(incTxBytes), this, SLOT(incTxBytes)); + connect(ssi, SIGNAL(incTxBytes(qint64)), this, SLOT(incTxBytes(qint64))); ssi->moveToThread(pool->thread()); pool->addClient(); connect(ssi, SIGNAL(destroyed()), pool, SLOT(removeClient())); @@ -155,7 +155,7 @@ void Servatrice_WebsocketGameServer::onNewConnection() Servatrice_ConnectionPool *pool = findLeastUsedConnectionPool(); auto ssi = new WebsocketServerSocketInterface(server, pool->getDatabaseInterface()); - connect(ssi, SIGNAL(incTxBytes), this, SLOT(incTxBytes)); + connect(ssi, SIGNAL(incTxBytes(quint64)), this, SLOT(incTxBytes(quint64))); /* * Due to a Qt limitation, websockets can't be moved to another thread. * This will hopefully change in Qt6 if QtWebSocket will be integrated in QtNetwork diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index ee6fa6c8..40d4820c 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -1701,9 +1701,14 @@ TcpServerSocketInterface::TcpServerSocketInterface(Servatrice *_server, socket = new QTcpSocket(this); socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); connect(socket, SIGNAL(readyRead()), this, SLOT(readClient())); + connect(socket, SIGNAL(disconnected()), this, SLOT(catchSocketDisconnected())); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, + SLOT(catchSocketError(QAbstractSocket::SocketError))); +#else connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError))); - connect(socket, SIGNAL(disconnected()), this, SLOT(catchSocketDisconnected())); +#endif } TcpServerSocketInterface::~TcpServerSocketInterface()