don’t have AvatarMixer ask DS for agents

This commit is contained in:
Stephen Birarda 2013-10-08 11:07:46 -07:00
parent 76cecb43cf
commit 40dd698293
4 changed files with 20 additions and 11 deletions

View file

@ -98,7 +98,7 @@ void AvatarMixer::run() {
nodeList->startSilentNodeRemovalThread();
sockaddr* nodeAddress = new sockaddr;
sockaddr nodeAddress = {};
ssize_t receivedBytes = 0;
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
@ -107,8 +107,6 @@ void AvatarMixer::run() {
Node* avatarNode = NULL;
timeval lastDomainServerCheckIn = {};
// we only need to hear back about avatar nodes from the DS
nodeList->setNodeTypesOfInterest(&NODE_TYPE_AGENT, 1);
while (true) {
@ -122,7 +120,7 @@ void AvatarMixer::run() {
NodeList::getInstance()->sendDomainServerCheckIn(_uuid.toRfc4122().constData());
}
if (nodeList->getNodeSocket()->receive(nodeAddress, packetData, &receivedBytes) &&
if (nodeList->getNodeSocket()->receive(&nodeAddress, packetData, &receivedBytes) &&
packetVersionMatch(packetData)) {
switch (packetData[0]) {
case PACKET_TYPE_HEAD_DATA:
@ -130,12 +128,12 @@ void AvatarMixer::run() {
unpackNodeId(packetData + numBytesForPacketHeader(packetData), &nodeID);
// add or update the node in our list
avatarNode = nodeList->addOrUpdateNode(nodeAddress, nodeAddress, NODE_TYPE_AGENT, nodeID);
avatarNode = nodeList->addOrUpdateNode(&nodeAddress, &nodeAddress, NODE_TYPE_AGENT, nodeID);
// parse positional data from an node
nodeList->updateNodeWithData(avatarNode, packetData, receivedBytes);
case PACKET_TYPE_INJECT_AUDIO:
broadcastAvatarData(nodeList, nodeAddress);
broadcastAvatarData(nodeList, &nodeAddress);
break;
case PACKET_TYPE_AVATAR_URLS:
case PACKET_TYPE_AVATAR_FACE_VIDEO:
@ -151,7 +149,7 @@ void AvatarMixer::run() {
break;
default:
// hand this off to the NodeList
nodeList->processNodeData(nodeAddress, packetData, receivedBytes);
nodeList->processNodeData(&nodeAddress, packetData, receivedBytes);
break;
}
}

View file

@ -428,18 +428,23 @@ void NodeList::sendAssignment(Assignment& assignment) {
}
Node* NodeList::addOrUpdateNode(sockaddr* publicSocket, sockaddr* localSocket, char nodeType, uint16_t nodeId) {
qDebug() << "BEGIN:" << publicSocket << "and" << localSocket << "\n";
NodeList::iterator node = end();
if (publicSocket) {
for (node = begin(); node != end(); node++) {
qDebug() << "comparing to node with ID " << node->getNodeID() << "\n";
if (node->matches(publicSocket, localSocket, nodeType)) {
// we already have this node, stop checking
qDebug() << "Matched node to existing\n";
break;
}
}
}
if (node == end()) {
if (node == end()) {
qDebug() << "We're considering this a new node!\n";
qDebug() << publicSocket << "and" << localSocket << "\n";
// we didn't have this node, so add them
Node* newNode = new Node(publicSocket, localSocket, nodeType, nodeId);
@ -540,6 +545,10 @@ void* removeSilentNodes(void *args) {
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
node->lock();
qDebug() << "This node's LHMS is" << node->getLastHeardMicrostamp() << "\n";
if ((checkTimeUSecs - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS) {
qDebug() << "Killed " << *node << "\n";
@ -548,6 +557,8 @@ void* removeSilentNodes(void *args) {
node->setAlive(false);
}
node->unlock();
}
sleepTime = NODE_SILENCE_THRESHOLD_USECS - (usecTimestampNow() - checkTimeUSecs);

View file

@ -30,7 +30,7 @@ const int NODES_PER_BUCKET = 100;
const int MAX_PACKET_SIZE = 1500;
const int NODE_SILENCE_THRESHOLD_USECS = 2 * 1000000;
const uint64_t NODE_SILENCE_THRESHOLD_USECS = 2 * 1000000;
const int DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000;
extern const char SOLO_NODE_TYPES[2];

View file

@ -43,7 +43,7 @@ bool socketMatch(const sockaddr* first, const sockaddr* second) {
const sockaddr_in *secondIn = (const sockaddr_in *) second;
return firstIn->sin_addr.s_addr == secondIn->sin_addr.s_addr
&& firstIn->sin_port == secondIn->sin_port;
&& firstIn->sin_port == secondIn->sin_port;
} else {
return false;
}
@ -254,7 +254,7 @@ bool UDPSocket::receive(sockaddr* recvAddress, void* receivedData, ssize_t* rece
#ifdef _WIN32
int addressSize = sizeof(*recvAddress);
#else
socklen_t addressSize = sizeof(&recvAddress);
socklen_t addressSize = sizeof(*recvAddress);
#endif
*receivedBytes = recvfrom(handle, static_cast<char*>(receivedData), MAX_BUFFER_LENGTH_BYTES,
0, recvAddress, &addressSize);