mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
handle immediate add packets in NodeList
This commit is contained in:
parent
5c75863af4
commit
cee058c4ce
4 changed files with 53 additions and 26 deletions
|
@ -490,6 +490,10 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
|||
// we didn't have this node, so add them
|
||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, canAdjustLocks, canRez, connectionSecret);
|
||||
|
||||
if (nodeType == NodeType::AudioMixer) {
|
||||
LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer);
|
||||
}
|
||||
|
||||
SharedNodePointer newNodePointer(newNode);
|
||||
|
||||
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
SetDomainSocket,
|
||||
SendDSCheckIn,
|
||||
ReceiveDSList,
|
||||
AddedAudioMixer,
|
||||
SendAudioPing,
|
||||
SetAudioMixerSocket,
|
||||
SendAudioPacket,
|
||||
|
|
|
@ -170,12 +170,18 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer&
|
|||
}
|
||||
|
||||
void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) {
|
||||
switch (packetTypeForPacket(packet)) {
|
||||
case PacketTypeDomainList: {
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
switch (packetType) {
|
||||
case PacketTypeDomainList:
|
||||
case PacketTypeDomainServerAddedNode: {
|
||||
if (!_domainHandler.getSockAddr().isNull()) {
|
||||
// only process a list from domain-server if we're talking to a domain
|
||||
// only process a packet from domain-server if we're talking to a domain
|
||||
// TODO: how do we make sure this is actually the domain we want the list from (DTLS probably)
|
||||
processDomainServerList(packet);
|
||||
if (packetType == PacketTypeDomainList) {
|
||||
processDomainServerList(packet);
|
||||
} else if (packetType == PacketTypeDomainServerAddedNode) {
|
||||
processDomainServerAddedNode(packet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -525,31 +531,44 @@ int NodeList::processDomainServerList(const QByteArray& packet) {
|
|||
|
||||
// pull each node in the packet
|
||||
while (packetStream.device()->pos() < packet.size()) {
|
||||
// setup variables to read into from QDataStream
|
||||
qint8 nodeType;
|
||||
QUuid nodeUUID, connectionUUID;
|
||||
HifiSockAddr nodePublicSocket, nodeLocalSocket;
|
||||
bool canAdjustLocks;
|
||||
bool canRez;
|
||||
|
||||
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> canAdjustLocks >> canRez;
|
||||
|
||||
// if the public socket address is 0 then it's reachable at the same IP
|
||||
// as the domain server
|
||||
if (nodePublicSocket.getAddress().isNull()) {
|
||||
nodePublicSocket.setAddress(_domainHandler.getIP());
|
||||
}
|
||||
|
||||
packetStream >> connectionUUID;
|
||||
|
||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
||||
nodeLocalSocket, canAdjustLocks, canRez,
|
||||
connectionUUID);
|
||||
parseNodeFromPacketStream(packetStream);
|
||||
}
|
||||
|
||||
return readNodes;
|
||||
}
|
||||
|
||||
void NodeList::processDomainServerAddedNode(const QByteArray& packet) {
|
||||
// setup a QDataStream, skip the header
|
||||
QDataStream packetStream(packet);
|
||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||
|
||||
// use our shared method to pull out the new node
|
||||
parseNodeFromPacketStream(packetStream);
|
||||
}
|
||||
|
||||
void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||
// setup variables to read into from QDataStream
|
||||
qint8 nodeType;
|
||||
QUuid nodeUUID, connectionUUID;
|
||||
HifiSockAddr nodePublicSocket, nodeLocalSocket;
|
||||
bool canAdjustLocks;
|
||||
bool canRez;
|
||||
|
||||
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> canAdjustLocks >> canRez;
|
||||
|
||||
// if the public socket address is 0 then it's reachable at the same IP
|
||||
// as the domain server
|
||||
if (nodePublicSocket.getAddress().isNull()) {
|
||||
nodePublicSocket.setAddress(_domainHandler.getIP());
|
||||
}
|
||||
|
||||
packetStream >> connectionUUID;
|
||||
|
||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
||||
nodeLocalSocket, canAdjustLocks, canRez,
|
||||
connectionUUID);
|
||||
}
|
||||
|
||||
void NodeList::sendAssignment(Assignment& assignment) {
|
||||
|
||||
PacketType assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
|
||||
|
|
|
@ -61,8 +61,6 @@ public:
|
|||
|
||||
void processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet);
|
||||
|
||||
int processDomainServerList(const QByteArray& packet);
|
||||
|
||||
void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
|
||||
void sendAssignment(Assignment& assignment);
|
||||
|
||||
|
@ -94,6 +92,11 @@ private:
|
|||
|
||||
void sendDSPathQuery(const QString& newPath);
|
||||
|
||||
int processDomainServerList(const QByteArray& packet);
|
||||
void processDomainServerAddedNode(const QByteArray& packet);
|
||||
void parseNodeFromPacketStream(QDataStream& packetStream);
|
||||
|
||||
|
||||
NodeType_t _ownerType;
|
||||
NodeSet _nodeTypesOfInterest;
|
||||
DomainHandler _domainHandler;
|
||||
|
|
Loading…
Reference in a new issue