Skip to content

Commit

Permalink
Assignment client type is not known at construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltdavid committed Aug 18, 2021
1 parent 5d15ebb commit ace612d
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion assignment-client/src/AssignmentClientMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen
// create a NodeList so we can receive stats from children
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
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();
packetReceiver.registerListener(PacketType::AssignmentClientStatus,
Expand Down
2 changes: 1 addition & 1 deletion domain-server/src/DomainServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
nodeList->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this,
Expand Down
4 changes: 2 additions & 2 deletions libraries/networking/src/LimitedNodeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ static Setting::Handle<quint16> 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>("ConnectionStep");
Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/LimitedNodeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ protected slots:
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

Expand Down
2 changes: 1 addition & 1 deletion libraries/networking/src/NodeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion libraries/networking/src/NodeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libraries/networking/src/udt/NetworkSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/udt/NetworkSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class NetworkSocket : public QObject {

/// @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.
Expand Down
4 changes: 2 additions & 2 deletions libraries/networking/src/udt/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/networking/src/udt/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Socket : public QObject {

public:
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); }

Expand Down
7 changes: 3 additions & 4 deletions libraries/networking/src/webrtc/WebRTCDataChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/webrtc/WebRTCDataChannels.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ class WebRTCDataChannels : public QObject {

/// @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();
Expand Down
4 changes: 2 additions & 2 deletions libraries/networking/src/webrtc/WebRTCSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions libraries/networking/src/webrtc/WebRTCSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class WebRTCSocket : public QObject {

/// @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.
Expand Down

0 comments on commit ace612d

Please sign in to comment.