From ace612d038d4a613089e2c8c0dc1a25aab58117a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Aug 2021 21:27:35 +1200 Subject: [PATCH] Assignment client type is not known at construction --- assignment-client/src/AssignmentClientMonitor.cpp | 2 +- domain-server/src/DomainServer.cpp | 2 +- libraries/networking/src/LimitedNodeList.cpp | 4 ++-- libraries/networking/src/LimitedNodeList.h | 3 +-- libraries/networking/src/NodeList.cpp | 2 +- libraries/networking/src/NodeList.h | 2 +- libraries/networking/src/udt/NetworkSocket.cpp | 4 ++-- libraries/networking/src/udt/NetworkSocket.h | 3 +-- libraries/networking/src/udt/Socket.cpp | 4 ++-- libraries/networking/src/udt/Socket.h | 4 ++-- libraries/networking/src/webrtc/WebRTCDataChannels.cpp | 7 +++---- libraries/networking/src/webrtc/WebRTCDataChannels.h | 3 +-- libraries/networking/src/webrtc/WebRTCSocket.cpp | 4 ++-- libraries/networking/src/webrtc/WebRTCSocket.h | 3 +-- 14 files changed, 21 insertions(+), 26 deletions(-) diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index a2e4d4a697..221a922a4b 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -70,7 +70,7 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen // create a NodeList so we can receive stats from children DependencyManager::registerInheritance(); auto addressManager = DependencyManager::set(); - auto nodeList = DependencyManager::set(NodeType::Unassigned, listenPort); + auto nodeList = DependencyManager::set(listenPort); auto& packetReceiver = DependencyManager::get()->getPacketReceiver(); packetReceiver.registerListener(PacketType::AssignmentClientStatus, diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 185250e809..569e662ae0 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -739,7 +739,7 @@ void DomainServer::setupNodeListAndAssignments() { // check for scripts the user wants to persist from their domain-server config populateStaticScriptedAssignmentsFromSettings(); - auto nodeList = DependencyManager::set(NodeType::DomainServer, domainServerPort, domainServerDTLSPort); + auto nodeList = DependencyManager::set(domainServerPort, domainServerDTLSPort); // no matter the local port, save it to shared mem so that local assignment clients can ask what it is nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this, diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index e742363373..8a551f55cb 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -50,8 +50,8 @@ static Setting::Handle LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.Loc using namespace std::chrono_literals; static const std::chrono::milliseconds CONNECTION_RATE_INTERVAL_MS = 1s; -LimitedNodeList::LimitedNodeList(char ownerType, int socketListenPort, int dtlsListenPort) : - _nodeSocket(this, true, ownerType), +LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) : + _nodeSocket(this, true), _packetReceiver(new PacketReceiver(this)) { qRegisterMetaType("ConnectionStep"); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 81d93bf935..2ee863da07 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -416,8 +416,7 @@ protected: QUuid connectionSecretUUID; }; - LimitedNodeList(char ownerType = NodeType::DomainServer, int socketListenPort = INVALID_PORT, - int dtlsListenPort = INVALID_PORT); + LimitedNodeList(int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 97080a349a..b8e6cdf80a 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -50,7 +50,7 @@ const int KEEPALIVE_PING_INTERVAL_MS = 1000; const int MAX_SYSTEM_INFO_SIZE = 1000; NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) : - LimitedNodeList(newOwnerType, socketListenPort, dtlsListenPort), + LimitedNodeList(socketListenPort, dtlsListenPort), _ownerType(newOwnerType), _nodeTypesOfInterest(), _domainHandler(this), diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index d3999c31f6..7af0dc405f 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -154,7 +154,7 @@ private slots: void maybeSendIgnoreSetToNode(SharedNodePointer node); private: - NodeList() : LimitedNodeList(NodeType::Unassigned, INVALID_PORT, INVALID_PORT) { + NodeList() : LimitedNodeList(INVALID_PORT, INVALID_PORT) { assert(false); // Not implemented, needed for DependencyManager templates compile } NodeList(char ownerType, int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); diff --git a/libraries/networking/src/udt/NetworkSocket.cpp b/libraries/networking/src/udt/NetworkSocket.cpp index c882f6dbe3..fd646fe317 100644 --- a/libraries/networking/src/udt/NetworkSocket.cpp +++ b/libraries/networking/src/udt/NetworkSocket.cpp @@ -11,13 +11,13 @@ #include "../NetworkLogging.h" -NetworkSocket::NetworkSocket(QObject* parent, NodeType_t nodeType) : +NetworkSocket::NetworkSocket(QObject* parent) : QObject(parent), _parent(parent), _udpSocket(this) #if defined(WEBRTC_DATA_CHANNELS) , - _webrtcSocket(this, nodeType) + _webrtcSocket(this) #endif { connect(&_udpSocket, &QUdpSocket::readyRead, this, &NetworkSocket::readyRead); diff --git a/libraries/networking/src/udt/NetworkSocket.h b/libraries/networking/src/udt/NetworkSocket.h index d5891cbde7..2670fa40b8 100644 --- a/libraries/networking/src/udt/NetworkSocket.h +++ b/libraries/networking/src/udt/NetworkSocket.h @@ -33,8 +33,7 @@ public: /// @brief Constructs a new NetworkSocket object. /// @param parent Qt parent object. - /// @param nodeType The type of node that the NetworkSocket object is being used in. - NetworkSocket(QObject* parent, NodeType_t nodeType); + NetworkSocket(QObject* parent); /// @brief Set the value of a UDP or WebRTC socket option. diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 810948d742..8313a87bbf 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -40,9 +40,9 @@ using namespace udt; #endif -Socket::Socket(QObject* parent, bool shouldChangeSocketOptions, NodeType_t nodeType) : +Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) : QObject(parent), - _networkSocket(parent, nodeType), + _networkSocket(parent), _readyReadBackupTimer(new QTimer(this)), _shouldChangeSocketOptions(shouldChangeSocketOptions) { diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 5c93d96676..ab9699bb8f 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -55,8 +55,8 @@ class Socket : public QObject { public: using StatsVector = std::vector>; - - Socket(QObject* object = 0, bool shouldChangeSocketOptions = true, NodeType_t nodeType = NodeType::Unassigned); + + Socket(QObject* object = 0, bool shouldChangeSocketOptions = true); quint16 localPort(SocketType socketType) const { return _networkSocket.localPort(socketType); } diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index c62bca72c4..3f7b84086d 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -373,13 +373,12 @@ void WDCConnection::closePeerConnection() { } -WebRTCDataChannels::WebRTCDataChannels(QObject* parent, NodeType_t nodeType) : +WebRTCDataChannels::WebRTCDataChannels(QObject* parent) : QObject(parent), - _parent(parent), - _nodeType(nodeType) + _parent(parent) { #ifdef WEBRTC_DEBUG - qCDebug(networking_webrtc) << "WebRTCDataChannels::WebRTCDataChannels()" << nodeType << NodeType::getNodeTypeName(nodeType); + qCDebug(networking_webrtc) << "WebRTCDataChannels::WebRTCDataChannels()"; #endif // Create a peer connection factory. diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.h b/libraries/networking/src/webrtc/WebRTCDataChannels.h index f6287c3717..b1751093d5 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.h +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.h @@ -227,8 +227,7 @@ public: /// @brief Constructs a new WebRTCDataChannels object. /// @param parent The parent Qt object. - /// @param nodeType The type of node that the WebRTCDataChannels object is being used in. - WebRTCDataChannels(QObject* parent, NodeType_t nodeType); + WebRTCDataChannels(QObject* parent); /// @brief Destroys a WebRTCDataChannels object. ~WebRTCDataChannels(); diff --git a/libraries/networking/src/webrtc/WebRTCSocket.cpp b/libraries/networking/src/webrtc/WebRTCSocket.cpp index 2247ad8615..69b97ebf94 100644 --- a/libraries/networking/src/webrtc/WebRTCSocket.cpp +++ b/libraries/networking/src/webrtc/WebRTCSocket.cpp @@ -16,9 +16,9 @@ #include "../udt/Constants.h" -WebRTCSocket::WebRTCSocket(QObject* parent, NodeType_t nodeType) : +WebRTCSocket::WebRTCSocket(QObject* parent) : QObject(parent), - _dataChannels(this, nodeType) + _dataChannels(this) { // Route signaling messages. connect(this, &WebRTCSocket::onSignalingMessage, &_dataChannels, &WebRTCDataChannels::onSignalingMessage); diff --git a/libraries/networking/src/webrtc/WebRTCSocket.h b/libraries/networking/src/webrtc/WebRTCSocket.h index 9a1d6442d7..8e429673e1 100644 --- a/libraries/networking/src/webrtc/WebRTCSocket.h +++ b/libraries/networking/src/webrtc/WebRTCSocket.h @@ -31,8 +31,7 @@ public: /// @brief Constructs a new WebRTCSocket object. /// @param parent Qt parent object. - /// @param nodeType The type of node that the WebRTCsocket object is being used in. - WebRTCSocket(QObject* parent, NodeType_t nodeType); + WebRTCSocket(QObject* parent); /// @brief Nominally sets the value of a socket option.