use a proper string list in DataServer for values

This commit is contained in:
Stephen Birarda 2014-01-30 12:14:28 -08:00
parent 910b97de21
commit 2294b3a2cd

View file

@ -152,7 +152,7 @@ void DataServer::readPendingDatagrams() {
sendPacketStream << keyListString; sendPacketStream << keyListString;
QStringList keyList = keyListString.split(MULTI_KEY_VALUE_SEPARATOR); QStringList keyList = keyListString.split(MULTI_KEY_VALUE_SEPARATOR);
QString valueList; QStringList 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",
@ -164,21 +164,17 @@ void DataServer::readPendingDatagrams() {
if (reply->len) { if (reply->len) {
// copy the value that redis returned // copy the value that redis returned
valueList.append(reply->str); valueList << reply->str;
} else { } else {
// didn't find a value - insert a space // didn't find a value - insert a space
valueList.append(' '); valueList << QChar(' ');
} }
// add the multi-value separator
valueList.append(MULTI_KEY_VALUE_SEPARATOR);
freeReplyObject(reply); freeReplyObject(reply);
} }
// null terminate the packet we're sending back (erases the trailing separator) // append the value QStringList using the right separator
valueList[valueList.size() - 1] = '\0'; sendPacketStream << valueList.join(MULTI_KEY_VALUE_SEPARATOR);
sendPacketStream << valueList;
} else { } else {
// user was asking for their UUID // user was asking for their UUID
sendPacketStream << userString; sendPacketStream << userString;