Start new hole punch when the socket is updated

This commit is contained in:
Atlante45 2016-08-18 17:54:52 -07:00
parent 78cf81954c
commit d938e518a0
5 changed files with 14 additions and 0 deletions

View file

@ -606,6 +606,12 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
});
}
// Signal when a socket changes, so we can start the hole punch over.
auto weakPtr = newNodePointer.toWeakRef(); // We don't want the lambda to hold a strong ref
connect(newNodePointer.data(), &NetworkPeer::socketUpdated, this, [=] {
emit nodeUpdated(weakPtr);
});
return newNodePointer;
}
}

View file

@ -250,6 +250,7 @@ signals:
void uuidChanged(const QUuid& ownerUUID, const QUuid& oldUUID);
void nodeAdded(SharedNodePointer);
void nodeUpdated(SharedNodePointer);
void nodeKilled(SharedNodePointer);
void nodeActivated(SharedNodePointer);

View file

@ -63,6 +63,7 @@ void NetworkPeer::setPublicSocket(const HifiSockAddr& publicSocket) {
if (!wasOldSocketNull) {
qCDebug(networking) << "Public socket change for node" << *this;
emit socketUpdated();
}
}
}
@ -82,6 +83,7 @@ void NetworkPeer::setLocalSocket(const HifiSockAddr& localSocket) {
if (!wasOldSocketNull) {
qCDebug(networking) << "Local socket change for node" << *this;
emit socketUpdated();
}
}
}
@ -101,6 +103,7 @@ void NetworkPeer::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
if (!wasOldSocketNull) {
qCDebug(networking) << "Symmetric socket change for node" << *this;
emit socketUpdated();
}
}
}

View file

@ -81,9 +81,12 @@ public:
public slots:
void startPingTimer();
void stopPingTimer();
signals:
void pingTimerTimeout();
void socketActivated(const HifiSockAddr& sockAddr);
void socketUpdated();
protected:
void setActiveSocket(HifiSockAddr* discoveredSocket);

View file

@ -93,6 +93,7 @@ NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned
// anytime we get a new node we will want to attempt to punch to it
connect(this, &LimitedNodeList::nodeAdded, this, &NodeList::startNodeHolePunch);
connect(this, &LimitedNodeList::nodeUpdated, this, &NodeList::startNodeHolePunch);
// anytime we get a new node we may need to re-send our set of ignored node IDs to it
connect(this, &LimitedNodeList::nodeActivated, this, &NodeList::maybeSendIgnoreSetToNode);