amnezia-client/service/server/localserver.cpp
Mortie 8c20a67cfa migrated the codebase to Qt6 and fixed some compatibility issues
* used a Qt6 ported version of SortFilterProxyModel
* used an updated Qt6 compatible version of QXZing
* added a flag to windows linker to avoid WinMain problem of MSVCRTD
* renamed utils.cpp to utilities.cpp for avoiding confusion with the same file name in SortFilterProxyModel
2022-08-29 12:21:09 +04:30

43 lines
1.1 KiB
C++

#include <QCoreApplication>
#include <QFileInfo>
#include <QLocalServer>
#include <QLocalSocket>
#include "ipc.h"
#include "localserver.h"
#include "utilities.h"
#include "router.h"
#ifdef Q_OS_WIN
#include "tapcontroller_win.h"
#endif
LocalServer::LocalServer(QObject *parent) : QObject(parent),
m_ipcServer(this)
{
// Create the server and listen outside of QtRO
m_server = QSharedPointer<QLocalServer>(new QLocalServer(this));
m_server->setSocketOptions(QLocalServer::WorldAccessOption);
if (!m_server->listen(amnezia::getIpcServiceUrl())) {
qDebug() << QString("Unable to start the server: %1.").arg(m_server->errorString());
return;
}
QObject::connect(m_server.data(), &QLocalServer::newConnection, this, [this]() {
qDebug() << "LocalServer new connection";
m_serverNode.addHostSideConnection(m_server->nextPendingConnection());
if (!m_isRemotingEnabled) {
m_isRemotingEnabled = true;
m_serverNode.enableRemoting(&m_ipcServer);
}
});
}
LocalServer::~LocalServer()
{
qDebug() << "Local server stopped";
}