mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
WIP - assign short IDs to nodes and distribute them.
This commit is contained in:
parent
b5f165d481
commit
4ec77e3af6
6 changed files with 34 additions and 7 deletions
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
void removeICEPeer(const QUuid& peerUUID) { _icePeers.remove(peerUUID); }
|
||||
|
||||
Node::LocalID findOrCreateLocalID(const QUuid& uuid);
|
||||
|
||||
static void sendProtocolMismatchConnectionDenial(const HifiSockAddr& senderSockAddr);
|
||||
public slots:
|
||||
void processConnectRequestPacket(QSharedPointer<ReceivedMessage> message);
|
||||
|
@ -123,7 +125,6 @@ private:
|
|||
|
||||
// Local ID management.
|
||||
void initLocalIDManagement();
|
||||
Node::LocalID findOrCreateLocalID(const QUuid& uuid);
|
||||
struct UuidHash {
|
||||
size_t operator()(const QUuid& uuid) const { return qHash(uuid); }
|
||||
};
|
||||
|
|
|
@ -691,6 +691,10 @@ void DomainServer::setupNodeListAndAssignments() {
|
|||
}
|
||||
}
|
||||
|
||||
// Create our own short session ID.
|
||||
Node::LocalID serverSessionLocalID = _gatekeeper.findOrCreateLocalID(nodeList->getSessionUUID());
|
||||
nodeList->setSessionLocalID(serverSessionLocalID);
|
||||
|
||||
if (isMetaverseDomain) {
|
||||
// see if we think we're a temp domain (we have an API key) or a full domain
|
||||
const auto& temporaryDomainKey = DependencyManager::get<AccountManager>()->getTemporaryDomainKey(getID());
|
||||
|
@ -1165,6 +1169,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
|
||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||
extendedHeaderStream << node->getUUID();
|
||||
extendedHeaderStream << node->getLocalID();
|
||||
extendedHeaderStream << node->getPermissions();
|
||||
|
||||
auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader);
|
||||
|
|
|
@ -131,6 +131,15 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
|
|||
}
|
||||
}
|
||||
|
||||
Node::LocalID LimitedNodeList::getSessionLocalID() const {
|
||||
return _sessionLocalID;
|
||||
}
|
||||
|
||||
void LimitedNodeList::setSessionLocalID(Node::LocalID sessionLocalID) {
|
||||
QWriteLocker lock { &_sessionUUIDLock }; // Necessary?
|
||||
_sessionLocalID = sessionLocalID;
|
||||
}
|
||||
|
||||
void LimitedNodeList::setPermissions(const NodePermissions& newPermissions) {
|
||||
NodePermissions originalPermissions = _permissions;
|
||||
|
||||
|
|
|
@ -106,6 +106,8 @@ public:
|
|||
Q_ENUM(ConnectionStep);
|
||||
QUuid getSessionUUID() const;
|
||||
void setSessionUUID(const QUuid& sessionUUID);
|
||||
Node::LocalID getSessionLocalID() const;
|
||||
void setSessionLocalID(Node::LocalID localID);
|
||||
|
||||
void setPermissions(const NodePermissions& newPermissions);
|
||||
bool isAllowedEditor() const { return _permissions.can(NodePermissions::Permission::canAdjustLocks); }
|
||||
|
@ -427,6 +429,7 @@ private slots:
|
|||
private:
|
||||
mutable QReadWriteLock _sessionUUIDLock;
|
||||
QUuid _sessionUUID;
|
||||
Node::LocalID _sessionLocalID { 0 };
|
||||
};
|
||||
|
||||
#endif // hifi_LimitedNodeList_h
|
||||
|
|
|
@ -168,6 +168,7 @@ QDataStream& operator<<(QDataStream& out, const Node& node) {
|
|||
out << node._localSocket;
|
||||
out << node._permissions;
|
||||
out << node._isReplicated;
|
||||
out << node._localID;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -178,6 +179,7 @@ QDataStream& operator>>(QDataStream& in, Node& node) {
|
|||
in >> node._localSocket;
|
||||
in >> node._permissions;
|
||||
in >> node._isReplicated;
|
||||
in >> node._localID;
|
||||
return in;
|
||||
}
|
||||
|
||||
|
@ -188,7 +190,7 @@ QDebug operator<<(QDebug debug, const Node& node) {
|
|||
} else {
|
||||
debug.nospace() << " (" << node.getType() << ")";
|
||||
}
|
||||
debug << " " << node.getUUID().toString().toLocal8Bit().constData() << " ";
|
||||
debug << " " << node.getUUID().toString().toLocal8Bit().constData() << "(" << node.getLocalID() << ") ";
|
||||
debug.nospace() << node.getPublicSocket() << "/" << node.getLocalSocket();
|
||||
return debug.nospace();
|
||||
}
|
||||
|
|
|
@ -594,9 +594,13 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
|
|||
return;
|
||||
}
|
||||
|
||||
// pull our owner UUID from the packet, it's always the first thing
|
||||
// pull our owner (ie. session) UUID from the packet, it's always the first thing
|
||||
// The short (16 bit) ID comes next.
|
||||
QUuid newUUID;
|
||||
Node::LocalID newLocalID;
|
||||
packetStream >> newUUID;
|
||||
packetStream >> newLocalID;
|
||||
setSessionLocalID(newLocalID);
|
||||
setSessionUUID(newUUID);
|
||||
|
||||
// if this was the first domain-server list from this domain, we've now connected
|
||||
|
@ -638,12 +642,14 @@ void NodeList::processDomainServerRemovedNode(QSharedPointer<ReceivedMessage> me
|
|||
void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||
// setup variables to read into from QDataStream
|
||||
qint8 nodeType;
|
||||
QUuid nodeUUID, connectionUUID;
|
||||
QUuid nodeUUID, connectionSecretUUID;
|
||||
HifiSockAddr nodePublicSocket, nodeLocalSocket;
|
||||
NodePermissions permissions;
|
||||
bool isReplicated;
|
||||
Node::LocalID sessionLocalID;
|
||||
|
||||
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> permissions >> isReplicated;
|
||||
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> permissions
|
||||
>> isReplicated >> sessionLocalID;
|
||||
|
||||
// if the public socket address is 0 then it's reachable at the same IP
|
||||
// as the domain server
|
||||
|
@ -651,10 +657,11 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
|||
nodePublicSocket.setAddress(_domainHandler.getIP());
|
||||
}
|
||||
|
||||
packetStream >> connectionUUID;
|
||||
packetStream >> connectionSecretUUID;
|
||||
|
||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
||||
nodeLocalSocket, isReplicated, false, connectionUUID, permissions);
|
||||
nodeLocalSocket, isReplicated, false, connectionSecretUUID, permissions);
|
||||
node->setLocalID(sessionLocalID);
|
||||
|
||||
// nodes that are downstream or upstream of our own type are kept alive when we hear about them from the domain server
|
||||
// and always have their public socket as their active socket
|
||||
|
|
Loading…
Reference in a new issue