mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
weak pointers to nodeList
This commit is contained in:
parent
1ba28de5b6
commit
9806bce403
6 changed files with 50 additions and 25 deletions
|
@ -264,7 +264,8 @@ void DomainGatekeeper::updateNodePermissions() {
|
||||||
QList<SharedNodePointer> nodesToKill;
|
QList<SharedNodePointer> nodesToKill;
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
limitedNodeList->eachNode([this, &limitedNodeList, &nodesToKill](const SharedNodePointer& node){
|
QWeakPointer<LimitedNodeList> limitedNodeListWeak = limitedNodeList;
|
||||||
|
limitedNodeList->eachNode([this, limitedNodeListWeak, &nodesToKill](const SharedNodePointer& node){
|
||||||
// the id and the username in NodePermissions will often be the same, but id is set before
|
// the id and the username in NodePermissions will often be the same, but id is set before
|
||||||
// authentication and verifiedUsername is only set once they user's key has been confirmed.
|
// authentication and verifiedUsername is only set once they user's key has been confirmed.
|
||||||
QString verifiedUsername = node->getPermissions().getVerifiedUserName();
|
QString verifiedUsername = node->getPermissions().getVerifiedUserName();
|
||||||
|
@ -296,7 +297,8 @@ void DomainGatekeeper::updateNodePermissions() {
|
||||||
machineFingerprint = nodeData->getMachineFingerprint();
|
machineFingerprint = nodeData->getMachineFingerprint();
|
||||||
|
|
||||||
auto sendingAddress = nodeData->getSendingSockAddr().getAddress();
|
auto sendingAddress = nodeData->getSendingSockAddr().getAddress();
|
||||||
isLocalUser = (sendingAddress == limitedNodeList->getLocalSockAddr().getAddress() ||
|
auto nodeList = limitedNodeListWeak.lock();
|
||||||
|
isLocalUser = ((nodeList && sendingAddress == nodeList->getLocalSockAddr().getAddress()) ||
|
||||||
sendingAddress == QHostAddress::LocalHost);
|
sendingAddress == QHostAddress::LocalHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1198,6 +1198,7 @@ QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, con
|
||||||
void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) {
|
void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) {
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
QWeakPointer<LimitedNodeList> limitedNodeListWeak = limitedNodeList;
|
||||||
|
|
||||||
auto addNodePacket = NLPacket::create(PacketType::DomainServerAddedNode);
|
auto addNodePacket = NLPacket::create(PacketType::DomainServerAddedNode);
|
||||||
|
|
||||||
|
@ -1217,16 +1218,19 @@ void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[this, &addNodePacket, connectionSecretIndex, addedNode, &limitedNodeList](const SharedNodePointer& node) {
|
[this, &addNodePacket, connectionSecretIndex, addedNode, limitedNodeListWeak](const SharedNodePointer& node) {
|
||||||
addNodePacket->seek(connectionSecretIndex);
|
|
||||||
|
|
||||||
QByteArray rfcConnectionSecret = connectionSecretForNodes(node, addedNode).toRfc4122();
|
|
||||||
|
|
||||||
// replace the bytes at the end of the packet for the connection secret between these nodes
|
|
||||||
addNodePacket->write(rfcConnectionSecret);
|
|
||||||
|
|
||||||
// send off this packet to the node
|
// send off this packet to the node
|
||||||
limitedNodeList->sendUnreliablePacket(*addNodePacket, *node);
|
auto limitedNodeList = limitedNodeListWeak.lock();
|
||||||
|
if (limitedNodeList) {
|
||||||
|
addNodePacket->seek(connectionSecretIndex);
|
||||||
|
|
||||||
|
QByteArray rfcConnectionSecret = connectionSecretForNodes(node, addedNode).toRfc4122();
|
||||||
|
|
||||||
|
// replace the bytes at the end of the packet for the connection secret between these nodes
|
||||||
|
addNodePacket->write(rfcConnectionSecret);
|
||||||
|
|
||||||
|
limitedNodeList->sendUnreliablePacket(*addNodePacket, *node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1138,8 +1138,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
// setup a timer for domain-server check ins
|
// setup a timer for domain-server check ins
|
||||||
QTimer* domainCheckInTimer = new QTimer(this);
|
QTimer* domainCheckInTimer = new QTimer(this);
|
||||||
connect(domainCheckInTimer, &QTimer::timeout, [this, &nodeList] {
|
QWeakPointer<NodeList> nodeListWeak = nodeList;
|
||||||
if (!isServerlessMode()) {
|
connect(domainCheckInTimer, &QTimer::timeout, [this, nodeListWeak] {
|
||||||
|
auto nodeList = nodeListWeak.lock();
|
||||||
|
if (!isServerlessMode() && nodeList) {
|
||||||
nodeList->sendDomainServerCheckIn();
|
nodeList->sendDomainServerCheckIn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -333,16 +333,21 @@ void AvatarManager::postUpdate(float deltaTime, const render::ScenePointer& scen
|
||||||
|
|
||||||
void AvatarManager::sendIdentityRequest(const QUuid& avatarID) const {
|
void AvatarManager::sendIdentityRequest(const QUuid& avatarID) const {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
QWeakPointer<NodeList> nodeListWeak = nodeList;
|
||||||
nodeList->eachMatchingNode(
|
nodeList->eachMatchingNode(
|
||||||
[](const SharedNodePointer& node)->bool {
|
[](const SharedNodePointer& node)->bool {
|
||||||
return node->getType() == NodeType::AvatarMixer && node->getActiveSocket();
|
return node->getType() == NodeType::AvatarMixer && node->getActiveSocket();
|
||||||
},
|
},
|
||||||
[this, avatarID, &nodeList](const SharedNodePointer& node) {
|
[this, avatarID, nodeListWeak](const SharedNodePointer& node) {
|
||||||
auto packet = NLPacket::create(PacketType::AvatarIdentityRequest, NUM_BYTES_RFC4122_UUID, true);
|
auto nodeList = nodeListWeak.lock();
|
||||||
packet->write(avatarID.toRfc4122());
|
if (nodeList) {
|
||||||
nodeList->sendPacket(std::move(packet), *node);
|
auto packet = NLPacket::create(PacketType::AvatarIdentityRequest, NUM_BYTES_RFC4122_UUID, true);
|
||||||
++_identityRequestsSent;
|
packet->write(avatarID.toRfc4122());
|
||||||
});
|
nodeList->sendPacket(std::move(packet), *node);
|
||||||
|
++_identityRequestsSent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::simulateAvatarFades(float deltaTime) {
|
void AvatarManager::simulateAvatarFades(float deltaTime) {
|
||||||
|
|
|
@ -416,12 +416,24 @@ void setupPreferences() {
|
||||||
{
|
{
|
||||||
static const QString NETWORKING("Networking");
|
static const QString NETWORKING("Networking");
|
||||||
|
|
||||||
auto nodelist = DependencyManager::get<NodeList>();
|
QWeakPointer<NodeList> nodeListWeak = DependencyManager::get<NodeList>();
|
||||||
{
|
{
|
||||||
static const int MIN_PORT_NUMBER { 0 };
|
static const int MIN_PORT_NUMBER { 0 };
|
||||||
static const int MAX_PORT_NUMBER { 65535 };
|
static const int MAX_PORT_NUMBER { 65535 };
|
||||||
auto getter = [&nodelist] { return static_cast<int>(nodelist->getSocketLocalPort()); };
|
auto getter = [nodeListWeak] {
|
||||||
auto setter = [&nodelist](int preset) { nodelist->setSocketLocalPort(static_cast<quint16>(preset)); };
|
auto nodeList = nodeListWeak.lock();
|
||||||
|
if (nodeList) {
|
||||||
|
return static_cast<int>(nodeList->getSocketLocalPort());
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
auto setter = [nodeListWeak](int preset) {
|
||||||
|
auto nodeList = nodeListWeak.lock();
|
||||||
|
if (nodeList) {
|
||||||
|
nodeList->setSocketLocalPort(static_cast<quint16>(preset));
|
||||||
|
}
|
||||||
|
};
|
||||||
auto preference = new IntSpinnerPreference(NETWORKING, "Listening Port", getter, setter);
|
auto preference = new IntSpinnerPreference(NETWORKING, "Listening Port", getter, setter);
|
||||||
preference->setMin(MIN_PORT_NUMBER);
|
preference->setMin(MIN_PORT_NUMBER);
|
||||||
preference->setMax(MAX_PORT_NUMBER);
|
preference->setMax(MAX_PORT_NUMBER);
|
||||||
|
|
|
@ -331,7 +331,7 @@ void OffscreenQmlSurface::onRootCreated() {
|
||||||
getSurfaceContext()->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow()));
|
getSurfaceContext()->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow()));
|
||||||
|
|
||||||
// Connect with the audio client and listen for audio device changes
|
// Connect with the audio client and listen for audio device changes
|
||||||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::deviceChanged, this, [&](QAudio::Mode mode, const QAudioDeviceInfo& device) {
|
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::deviceChanged, this, [this](QAudio::Mode mode, const QAudioDeviceInfo& device) {
|
||||||
if (mode == QAudio::Mode::AudioOutput) {
|
if (mode == QAudio::Mode::AudioOutput) {
|
||||||
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection, Q_ARG(QString, device.deviceName()));
|
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection, Q_ARG(QString, device.deviceName()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue