Assignment client type is not known at construction

This commit is contained in:
David Rowe 2021-08-18 21:27:35 +12:00
parent 5d15ebb723
commit ace612d038
14 changed files with 21 additions and 26 deletions

View file

@ -70,7 +70,7 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen
// create a NodeList so we can receive stats from children // create a NodeList so we can receive stats from children
DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
auto addressManager = DependencyManager::set<AddressManager>(); auto addressManager = DependencyManager::set<AddressManager>();
auto nodeList = DependencyManager::set<LimitedNodeList>(NodeType::Unassigned, listenPort); auto nodeList = DependencyManager::set<LimitedNodeList>(listenPort);
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver(); auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListener(PacketType::AssignmentClientStatus, packetReceiver.registerListener(PacketType::AssignmentClientStatus,

View file

@ -739,7 +739,7 @@ void DomainServer::setupNodeListAndAssignments() {
// check for scripts the user wants to persist from their domain-server config // check for scripts the user wants to persist from their domain-server config
populateStaticScriptedAssignmentsFromSettings(); populateStaticScriptedAssignmentsFromSettings();
auto nodeList = DependencyManager::set<LimitedNodeList>(NodeType::DomainServer, domainServerPort, domainServerDTLSPort); auto nodeList = DependencyManager::set<LimitedNodeList>(domainServerPort, domainServerDTLSPort);
// no matter the local port, save it to shared mem so that local assignment clients can ask what it is // 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, nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this,

View file

@ -50,8 +50,8 @@ static Setting::Handle<quint16> LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.Loc
using namespace std::chrono_literals; using namespace std::chrono_literals;
static const std::chrono::milliseconds CONNECTION_RATE_INTERVAL_MS = 1s; static const std::chrono::milliseconds CONNECTION_RATE_INTERVAL_MS = 1s;
LimitedNodeList::LimitedNodeList(char ownerType, int socketListenPort, int dtlsListenPort) : LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
_nodeSocket(this, true, ownerType), _nodeSocket(this, true),
_packetReceiver(new PacketReceiver(this)) _packetReceiver(new PacketReceiver(this))
{ {
qRegisterMetaType<ConnectionStep>("ConnectionStep"); qRegisterMetaType<ConnectionStep>("ConnectionStep");

View file

@ -416,8 +416,7 @@ protected:
QUuid connectionSecretUUID; QUuid connectionSecretUUID;
}; };
LimitedNodeList(char ownerType = NodeType::DomainServer, int socketListenPort = INVALID_PORT, LimitedNodeList(int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT);
int dtlsListenPort = INVALID_PORT);
LimitedNodeList(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton 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 void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton

View file

@ -50,7 +50,7 @@ const int KEEPALIVE_PING_INTERVAL_MS = 1000;
const int MAX_SYSTEM_INFO_SIZE = 1000; const int MAX_SYSTEM_INFO_SIZE = 1000;
NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) : NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) :
LimitedNodeList(newOwnerType, socketListenPort, dtlsListenPort), LimitedNodeList(socketListenPort, dtlsListenPort),
_ownerType(newOwnerType), _ownerType(newOwnerType),
_nodeTypesOfInterest(), _nodeTypesOfInterest(),
_domainHandler(this), _domainHandler(this),

View file

@ -154,7 +154,7 @@ private slots:
void maybeSendIgnoreSetToNode(SharedNodePointer node); void maybeSendIgnoreSetToNode(SharedNodePointer node);
private: private:
NodeList() : LimitedNodeList(NodeType::Unassigned, INVALID_PORT, INVALID_PORT) { NodeList() : LimitedNodeList(INVALID_PORT, INVALID_PORT) {
assert(false); // Not implemented, needed for DependencyManager templates compile assert(false); // Not implemented, needed for DependencyManager templates compile
} }
NodeList(char ownerType, int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT); NodeList(char ownerType, int socketListenPort = INVALID_PORT, int dtlsListenPort = INVALID_PORT);

View file

@ -11,13 +11,13 @@
#include "../NetworkLogging.h" #include "../NetworkLogging.h"
NetworkSocket::NetworkSocket(QObject* parent, NodeType_t nodeType) : NetworkSocket::NetworkSocket(QObject* parent) :
QObject(parent), QObject(parent),
_parent(parent), _parent(parent),
_udpSocket(this) _udpSocket(this)
#if defined(WEBRTC_DATA_CHANNELS) #if defined(WEBRTC_DATA_CHANNELS)
, ,
_webrtcSocket(this, nodeType) _webrtcSocket(this)
#endif #endif
{ {
connect(&_udpSocket, &QUdpSocket::readyRead, this, &NetworkSocket::readyRead); connect(&_udpSocket, &QUdpSocket::readyRead, this, &NetworkSocket::readyRead);

View file

@ -33,8 +33,7 @@ public:
/// @brief Constructs a new NetworkSocket object. /// @brief Constructs a new NetworkSocket object.
/// @param parent Qt parent object. /// @param parent Qt parent object.
/// @param nodeType The type of node that the NetworkSocket object is being used in. NetworkSocket(QObject* parent);
NetworkSocket(QObject* parent, NodeType_t nodeType);
/// @brief Set the value of a UDP or WebRTC socket option. /// @brief Set the value of a UDP or WebRTC socket option.

View file

@ -40,9 +40,9 @@ using namespace udt;
#endif #endif
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions, NodeType_t nodeType) : Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
QObject(parent), QObject(parent),
_networkSocket(parent, nodeType), _networkSocket(parent),
_readyReadBackupTimer(new QTimer(this)), _readyReadBackupTimer(new QTimer(this)),
_shouldChangeSocketOptions(shouldChangeSocketOptions) _shouldChangeSocketOptions(shouldChangeSocketOptions)
{ {

View file

@ -55,8 +55,8 @@ class Socket : public QObject {
public: public:
using StatsVector = std::vector<std::pair<SockAddr, ConnectionStats::Stats>>; using StatsVector = std::vector<std::pair<SockAddr, ConnectionStats::Stats>>;
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); } quint16 localPort(SocketType socketType) const { return _networkSocket.localPort(socketType); }

View file

@ -373,13 +373,12 @@ void WDCConnection::closePeerConnection() {
} }
WebRTCDataChannels::WebRTCDataChannels(QObject* parent, NodeType_t nodeType) : WebRTCDataChannels::WebRTCDataChannels(QObject* parent) :
QObject(parent), QObject(parent),
_parent(parent), _parent(parent)
_nodeType(nodeType)
{ {
#ifdef WEBRTC_DEBUG #ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WebRTCDataChannels::WebRTCDataChannels()" << nodeType << NodeType::getNodeTypeName(nodeType); qCDebug(networking_webrtc) << "WebRTCDataChannels::WebRTCDataChannels()";
#endif #endif
// Create a peer connection factory. // Create a peer connection factory.

View file

@ -227,8 +227,7 @@ public:
/// @brief Constructs a new WebRTCDataChannels object. /// @brief Constructs a new WebRTCDataChannels object.
/// @param parent The parent Qt object. /// @param parent The parent Qt object.
/// @param nodeType The type of node that the WebRTCDataChannels object is being used in. WebRTCDataChannels(QObject* parent);
WebRTCDataChannels(QObject* parent, NodeType_t nodeType);
/// @brief Destroys a WebRTCDataChannels object. /// @brief Destroys a WebRTCDataChannels object.
~WebRTCDataChannels(); ~WebRTCDataChannels();

View file

@ -16,9 +16,9 @@
#include "../udt/Constants.h" #include "../udt/Constants.h"
WebRTCSocket::WebRTCSocket(QObject* parent, NodeType_t nodeType) : WebRTCSocket::WebRTCSocket(QObject* parent) :
QObject(parent), QObject(parent),
_dataChannels(this, nodeType) _dataChannels(this)
{ {
// Route signaling messages. // Route signaling messages.
connect(this, &WebRTCSocket::onSignalingMessage, &_dataChannels, &WebRTCDataChannels::onSignalingMessage); connect(this, &WebRTCSocket::onSignalingMessage, &_dataChannels, &WebRTCDataChannels::onSignalingMessage);

View file

@ -31,8 +31,7 @@ public:
/// @brief Constructs a new WebRTCSocket object. /// @brief Constructs a new WebRTCSocket object.
/// @param parent Qt parent object. /// @param parent Qt parent object.
/// @param nodeType The type of node that the WebRTCsocket object is being used in. WebRTCSocket(QObject* parent);
WebRTCSocket(QObject* parent, NodeType_t nodeType);
/// @brief Nominally sets the value of a socket option. /// @brief Nominally sets the value of a socket option.