mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
data-server repairs for get responses
This commit is contained in:
parent
d556119087
commit
49d04ce14e
1 changed files with 23 additions and 13 deletions
|
@ -133,17 +133,26 @@ void DataServer::readPendingDatagrams() {
|
||||||
// setup a send packet with the returned data
|
// setup a send packet with the returned data
|
||||||
// leverage the packetData sent by overwriting and appending
|
// leverage the packetData sent by overwriting and appending
|
||||||
QByteArray sendPacket = byteArrayWithPopluatedHeader(PacketTypeDataServerSend, _uuid);
|
QByteArray sendPacket = byteArrayWithPopluatedHeader(PacketTypeDataServerSend, _uuid);
|
||||||
sendPacket.append(sequenceNumber);
|
QDataStream sendPacketStream(&sendPacket, QIODevice::Append);
|
||||||
|
|
||||||
if (!receivedPacket.mid(numReceivedHeaderBytes + sizeof(sequenceNumber)).startsWith("uuid")) {
|
sendPacketStream << sequenceNumber;
|
||||||
|
|
||||||
|
// 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 = '|';
|
const char MULTI_KEY_VALUE_SEPARATOR = '|';
|
||||||
|
|
||||||
// pull the key that specifies the data the user is putting/getting, null terminate it
|
// append the keyListString back to the sendPacket
|
||||||
QString keyListString;
|
sendPacketStream << keyListString;
|
||||||
packetStream >> keyListString;
|
|
||||||
|
|
||||||
QStringList keyList = keyListString.split(MULTI_KEY_VALUE_SEPARATOR);
|
QStringList keyList = keyListString.split(MULTI_KEY_VALUE_SEPARATOR);
|
||||||
|
QString valueList;
|
||||||
|
|
||||||
foreach (const QString& dataKey, keyList) {
|
foreach (const QString& dataKey, keyList) {
|
||||||
qDebug("Sending command to redis: GET uuid:%s:%s",
|
qDebug("Sending command to redis: GET uuid:%s:%s",
|
||||||
|
@ -155,25 +164,26 @@ void DataServer::readPendingDatagrams() {
|
||||||
|
|
||||||
if (reply->len) {
|
if (reply->len) {
|
||||||
// copy the value that redis returned
|
// copy the value that redis returned
|
||||||
sendPacket.append(reply->str, reply->len);
|
valueList.append(reply->str);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// didn't find a value - insert a space
|
// didn't find a value - insert a space
|
||||||
sendPacket.append(' ');
|
valueList.append(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the multi-value separator
|
// add the multi-value separator
|
||||||
sendPacket.append(MULTI_KEY_VALUE_SEPARATOR);
|
valueList.append(MULTI_KEY_VALUE_SEPARATOR);
|
||||||
|
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null terminate the packet we're sending back (erases the trailing separator)
|
// null terminate the packet we're sending back (erases the trailing separator)
|
||||||
sendPacket[sendPacket.size() - 1] = '\0';
|
valueList[valueList.size() - 1] = '\0';
|
||||||
|
sendPacketStream << valueList;
|
||||||
} else {
|
} else {
|
||||||
// user is asking for a UUID matching username, copy the UUID we found
|
// user was asking for their UUID
|
||||||
sendPacket.append(uuidStringWithoutCurlyBraces(parsedUUID));
|
sendPacketStream << userString;
|
||||||
sendPacket.append('\0');
|
sendPacketStream << QString("uuid");
|
||||||
|
sendPacketStream << uuidStringWithoutCurlyBraces(parsedUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reply back with the send packet
|
// reply back with the send packet
|
||||||
|
|
Loading…
Reference in a new issue