mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
handle socketActivated
This commit is contained in:
parent
9c4286b6ca
commit
073215d067
2 changed files with 16 additions and 5 deletions
|
@ -84,7 +84,6 @@ void MessagesClient::subscribe(const QString& channel) {
|
||||||
auto packetList = NLPacketList::create(PacketType::MessagesSubscribe, QByteArray(), true, true);
|
auto packetList = NLPacketList::create(PacketType::MessagesSubscribe, QByteArray(), true, true);
|
||||||
packetList->write(channel.toUtf8());
|
packetList->write(channel.toUtf8());
|
||||||
nodeList->sendPacketList(std::move(packetList), *messagesMixer);
|
nodeList->sendPacketList(std::move(packetList), *messagesMixer);
|
||||||
qDebug() << "sending MessagesSubscribe for channel:" << channel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +101,20 @@ void MessagesClient::unsubscribe(const QString& channel) {
|
||||||
|
|
||||||
void MessagesClient::handleNodeAdded(SharedNodePointer node) {
|
void MessagesClient::handleNodeAdded(SharedNodePointer node) {
|
||||||
if (node->getType() == NodeType::MessagesMixer) {
|
if (node->getType() == NodeType::MessagesMixer) {
|
||||||
qDebug() << "messages-mixer node type added...";
|
if (!node->getActiveSocket()) {
|
||||||
for (const auto& channel : _subscribedChannels) {
|
connect(node.data(), &NetworkPeer::socketActivated, this, &MessagesClient::socketActivated);
|
||||||
qDebug() << "subscribing to channel:" << channel;
|
} else {
|
||||||
subscribe(channel);
|
resubscribeToAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesClient::socketActivated(const HifiSockAddr& sockAddr) {
|
||||||
|
resubscribeToAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagesClient::resubscribeToAll() {
|
||||||
|
for (const auto& channel : _subscribedChannels) {
|
||||||
|
subscribe(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -38,8 +38,10 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void handleMessagesPacket(QSharedPointer<NLPacketList> packetList, SharedNodePointer senderNode);
|
void handleMessagesPacket(QSharedPointer<NLPacketList> packetList, SharedNodePointer senderNode);
|
||||||
void handleNodeAdded(SharedNodePointer node);
|
void handleNodeAdded(SharedNodePointer node);
|
||||||
|
void socketActivated(const HifiSockAddr& sockAddr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void resubscribeToAll();
|
||||||
QSet<QString> _subscribedChannels;
|
QSet<QString> _subscribedChannels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue