Merge branch 'protocol' of github.com:Atlante45/hifi into protocol

This commit is contained in:
Ryan Huffman 2015-07-16 15:44:42 -07:00
commit c4526aa783
7 changed files with 27 additions and 28 deletions

View file

@ -219,7 +219,7 @@ void AvatarMixer::broadcastAvatarData() {
}
// setup a PacketList for the avatarPackets
NLPacketList avatarPacketList(PacketType::AvatarData);
NLPacketList avatarPacketList(PacketType::BulkAvatarData);
// this is an AGENT we have received head data from
// send back a packet with other active node data to this node

View file

@ -250,7 +250,7 @@ int OctreeInboundPacketProcessor::sendNackPackets() {
QUuid nodeUUID = i.key();
SingleSenderStats nodeStats = i.value();
// check if this node is still alive. Remove its stats if it's dead.
if (!isAlive(nodeUUID)) {
i = _singleSenderStats.erase(i);
@ -260,7 +260,7 @@ int OctreeInboundPacketProcessor::sendNackPackets() {
// if there are packets from _node that are waiting to be processed,
// don't send a NACK since the missing packets may be among those waiting packets.
if (hasPacketsToProcessFrom(nodeUUID)) {
i++;
++i;
continue;
}
@ -290,6 +290,8 @@ int OctreeInboundPacketProcessor::sendNackPackets() {
// send the list of nack packets
nodeList->sendPacketList(nackPacketList, *destinationNode);
}
++i;
}
return packetsSent;

View file

@ -374,21 +374,11 @@ const NLPacket* OctreeQueryNode::getNextNackedPacket() {
return nullptr;
}
void OctreeQueryNode::parseNackPacket(const QByteArray& packet) {
int numBytesPacketHeader = numBytesForPacketHeader(packet);
const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
// TODO: This no longer has the number of sequence numbers - just read to the end of the packet in sequence number blocks
// read number of sequence numbers
uint16_t numSequenceNumbers = (*(uint16_t*)dataAt);
dataAt += sizeof(uint16_t);
void OctreeQueryNode::parseNackPacket(NLPacket& packet) {
// read sequence numbers
for (int i = 0; i < numSequenceNumbers; i++) {
OCTREE_PACKET_SEQUENCE sequenceNumber = (*(OCTREE_PACKET_SEQUENCE*)dataAt);
while (packet.bytesLeftToRead()) {
OCTREE_PACKET_SEQUENCE sequenceNumber;
packet.readPrimitive(&sequenceNumber);
_nackedSequenceNumbers.enqueue(sequenceNumber);
dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
}
}

View file

@ -108,7 +108,7 @@ public:
OCTREE_PACKET_SEQUENCE getSequenceNumber() const { return _sequenceNumber; }
void parseNackPacket(const QByteArray& packet);
void parseNackPacket(NLPacket& packet);
bool hasNextNackedPacket() const;
const NLPacket* getNextNackedPacket();

View file

@ -813,14 +813,16 @@ void OctreeServer::parsePayload() {
}
void OctreeServer::handleOctreeQueryPacket(QSharedPointer<NLPacket> packet, SharedNodePointer senderNode) {
// If we got a query packet, then we're talking to an agent, and we
// need to make sure we have it in our nodeList.
auto nodeList = DependencyManager::get<NodeList>();
nodeList->updateNodeWithDataFromPacket(packet, senderNode);
OctreeQueryNode* nodeData = dynamic_cast<OctreeQueryNode*>(senderNode->getLinkedData());
if (nodeData && !nodeData->isOctreeSendThreadInitalized()) {
nodeData->initializeOctreeSendThread(this, senderNode);
if (!_isFinished) {
// If we got a query packet, then we're talking to an agent, and we
// need to make sure we have it in our nodeList.
auto nodeList = DependencyManager::get<NodeList>();
nodeList->updateNodeWithDataFromPacket(packet, senderNode);
OctreeQueryNode* nodeData = dynamic_cast<OctreeQueryNode*>(senderNode->getLinkedData());
if (nodeData && !nodeData->isOctreeSendThreadInitalized()) {
nodeData->initializeOctreeSendThread(this, senderNode);
}
}
}
@ -829,7 +831,7 @@ void OctreeServer::handleOctreeDataNackPacket(QSharedPointer<NLPacket> packet, S
// need to make sure we have it in our nodeList.
OctreeQueryNode* nodeData = dynamic_cast<OctreeQueryNode*>(senderNode->getLinkedData());
if (nodeData) {
nodeData->parseNackPacket(packet->getData());
nodeData->parseNackPacket(*packet);
}
}

View file

@ -82,6 +82,9 @@ void IceServer::processDatagrams() {
SharedNetworkPeer matchingPeer = _activePeers.value(connectRequestID);
if (matchingPeer) {
qDebug() << "Sending information for peer" << connectRequestID << "to peer" << senderUUID;
// we have the peer they want to connect to - send them pack the information for that peer
sendPeerInformationPacket(*(matchingPeer.data()), &sendingSockAddr);
@ -90,6 +93,8 @@ void IceServer::processDatagrams() {
NetworkPeer dummyPeer(senderUUID, publicSocket, localSocket);
sendPeerInformationPacket(dummyPeer, matchingPeer->getActiveSocket());
} else {
qDebug() << "Peer" << senderUUID << "asked for" << connectRequestID << "but no matching peer found";
}
}
}

View file

@ -22,7 +22,7 @@ AvatarHashMap::AvatarHashMap() {
connect(DependencyManager::get<NodeList>().data(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListener(PacketType::AvatarData, this, "processAvatarDataPacket");
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
packetReceiver.registerListener(PacketType::KillAvatar, this, "processKillAvatar");
packetReceiver.registerListener(PacketType::AvatarIdentity, this, "processAvatarIdentityPacket");
packetReceiver.registerListener(PacketType::AvatarBillboard, this, "processAvatarBillboardPacket");