File indexing completed on 2024-06-23 05:06:59
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org> * 0003 * * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later * 0005 ***************************************************************************/ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <QTcpServer> 0011 0012 class BridgeServerBase : public QObject 0013 { 0014 Q_OBJECT 0015 0016 public: 0017 explicit BridgeServerBase(quint16 port, QObject *parent = nullptr); 0018 0019 protected Q_SLOTS: 0020 virtual void slotNewConnection() = 0; 0021 0022 protected: 0023 QTcpServer *const m_server; 0024 }; 0025 0026 template<typename ConnectionType> 0027 class BridgeServer : public BridgeServerBase 0028 { 0029 public: 0030 explicit BridgeServer(quint16 port, QObject *parent = nullptr) 0031 : BridgeServerBase(port, parent) 0032 { 0033 } 0034 0035 protected: 0036 void slotNewConnection() override 0037 { 0038 while (m_server->hasPendingConnections()) { 0039 new ConnectionType(m_server->nextPendingConnection(), this); 0040 } 0041 } 0042 };