Merge branch 'master' of https://github.com/worklist/hifi into 19493

This commit is contained in:
stojce 2014-01-30 22:23:54 +01:00
commit 21ab08b31a
3 changed files with 29 additions and 18 deletions

View file

@ -133,17 +133,26 @@ void DataServer::readPendingDatagrams() {
// setup a send packet with the returned data
// leverage the packetData sent by overwriting and appending
QByteArray sendPacket = byteArrayWithPopluatedHeader(PacketTypeDataServerSend, _uuid);
sendPacket.append(sequenceNumber);
QDataStream sendPacketStream(&sendPacket, QIODevice::Append);
if (!receivedPacket.mid(numReceivedHeaderBytes + sizeof(sequenceNumber)).startsWith("uuid")) {
sendPacketStream << sequenceNumber;
const char MULTI_KEY_VALUE_SEPARATOR = '|';
// pull the key that specifies the data the user is putting/getting, null terminate it
// pull the key list that specifies the data the user is putting/getting
QString keyListString;
packetStream >> keyListString;
if (keyListString != "uuid") {
// copy the parsed UUID
sendPacketStream << uuidStringWithoutCurlyBraces(parsedUUID);
const char MULTI_KEY_VALUE_SEPARATOR = '|';
// append the keyListString back to the sendPacket
sendPacketStream << keyListString;
QStringList keyList = keyListString.split(MULTI_KEY_VALUE_SEPARATOR);
QStringList valueList;
foreach (const QString& dataKey, keyList) {
qDebug("Sending command to redis: GET uuid:%s:%s",
@ -155,25 +164,22 @@ void DataServer::readPendingDatagrams() {
if (reply->len) {
// copy the value that redis returned
sendPacket.append(reply->str, reply->len);
valueList << QString(reply->str);
} else {
// didn't find a value - insert a space
sendPacket.append(' ');
valueList << QChar(' ');
}
// add the multi-value separator
sendPacket.append(MULTI_KEY_VALUE_SEPARATOR);
freeReplyObject(reply);
}
// null terminate the packet we're sending back (erases the trailing separator)
sendPacket[sendPacket.size() - 1] = '\0';
// append the value QStringList using the right separator
sendPacketStream << valueList.join(MULTI_KEY_VALUE_SEPARATOR);
} else {
// user is asking for a UUID matching username, copy the UUID we found
sendPacket.append(uuidStringWithoutCurlyBraces(parsedUUID));
sendPacket.append('\0');
// user was asking for their UUID
sendPacketStream << userString;
sendPacketStream << QString("uuid");
sendPacketStream << uuidStringWithoutCurlyBraces(parsedUUID);
}
// reply back with the send packet

View file

@ -3225,7 +3225,8 @@ void Application::displayStats() {
glPointSize(1.0f);
int totalAvatars = _avatarManager.size();
// we need to take one avatar out so we don't include ourselves
int totalAvatars = _avatarManager.size() - 1;
int totalServers = NodeList::getInstance()->size();
if (mirrorEnabled) {

View file

@ -234,7 +234,11 @@ void AvatarManager::processAvatarMixerDatagram(const QByteArray& datagram, const
// copy the rest of the packet to the avatarData holder so we can read the next Avatar from there
dummyAvatarByteArray.resize(numDummyByteArrayHeaderBytes);
dummyAvatarByteArray += datagram.mid(bytesRead);
// make this Avatar's UUID the UUID in the packet and tack the remaining data onto the end
dummyAvatarByteArray.replace(numDummyByteArrayHeaderBytes - NUM_BYTES_RFC4122_UUID,
NUM_BYTES_RFC4122_UUID + datagram.size() - bytesRead,
datagram.mid(bytesRead));
// have the matching (or new) avatar parse the data from the packet
bytesRead += matchingAvatar->parseData(dummyAvatarByteArray);