more DataServerClient API tweaks

This commit is contained in:
Stephen Birarda 2014-01-21 13:13:57 -08:00
parent 3613773b79
commit e08f4d2eba
5 changed files with 34 additions and 34 deletions

View file

@ -1854,8 +1854,8 @@ void Application::init() {
if (!_profile.getUsername().isEmpty()) { if (!_profile.getUsername().isEmpty()) {
// we have a username for this avatar, ask the data-server for the mesh URL for this avatar // we have a username for this avatar, ask the data-server for the mesh URL for this avatar
DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL, _profile.getUsername(), &_profile); DataServerClient::getValueForKeyAndUserString(DataServerKey::FaceMeshURL, _profile.getUserString(), &_profile);
DataServerClient::getClientValueForKey(DataServerKey::SkeletonURL, _profile.getUsername(), &_profile); DataServerClient::getValueForKeyAndUserString(DataServerKey::SkeletonURL, _profile.getUserString(), &_profile);
} }
// Set up VoxelSystem after loading preferences so we can get the desired max voxel count // Set up VoxelSystem after loading preferences so we can get the desired max voxel count

View file

@ -830,9 +830,9 @@ void Menu::editPreferences() {
applicationInstance->getProfile()->setFaceModelURL(faceModelURL); applicationInstance->getProfile()->setFaceModelURL(faceModelURL);
// send the new face mesh URL to the data-server (if we have a client UUID) // send the new face mesh URL to the data-server (if we have a client UUID)
DataServerClient::putValueForKeyAndUsername(DataServerKey::FaceMeshURL, DataServerClient::putValueForKeyAndUserString(DataServerKey::FaceMeshURL,
faceModelURL.toString().toLocal8Bit().constData(), faceModelURL.toString().toLocal8Bit().constData(),
applicationInstance->getProfile()->getUsername()); applicationInstance->getProfile()->getUserString());
} }
QUrl skeletonModelURL(skeletonURLEdit->text()); QUrl skeletonModelURL(skeletonURLEdit->text());
@ -842,9 +842,9 @@ void Menu::editPreferences() {
applicationInstance->getProfile()->setSkeletonModelURL(skeletonModelURL); applicationInstance->getProfile()->setSkeletonModelURL(skeletonModelURL);
// send the new skeleton model URL to the data-server (if we have a client UUID) // send the new skeleton model URL to the data-server (if we have a client UUID)
DataServerClient::putValueForKeyAndUsername(DataServerKey::SkeletonURL, DataServerClient::putValueForKeyAndUserString(DataServerKey::SkeletonURL,
skeletonModelURL.toString().toLocal8Bit().constData(), skeletonModelURL.toString().toLocal8Bit().constData(),
applicationInstance->getProfile()->getUsername()); applicationInstance->getProfile()->getUserString());
} }
applicationInstance->getAvatar()->getHead().setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum()); applicationInstance->getAvatar()->getHead().setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum());
@ -963,7 +963,7 @@ void Menu::goToUser() {
int dialogReturn = userDialog.exec(); int dialogReturn = userDialog.exec();
if (dialogReturn == QDialog::Accepted && !userDialog.textValue().isEmpty()) { if (dialogReturn == QDialog::Accepted && !userDialog.textValue().isEmpty()) {
// there's a username entered by the user, make a request to the data-server // there's a username entered by the user, make a request to the data-server
DataServerClient::getValuesForKeysAndUsername( DataServerClient::getValuesForKeysAndUserString(
QStringList() << DataServerKey::Domain << DataServerKey::Position << DataServerKey::Orientation, QStringList() << DataServerKey::Domain << DataServerKey::Position << DataServerKey::Orientation,
userDialog.textValue(), Application::getInstance()->getProfile()); userDialog.textValue(), Application::getInstance()->getProfile());
} }

View file

@ -27,9 +27,9 @@ Profile::Profile(const QString &username) :
setUsername(username); setUsername(username);
// we've been given a new username, ask the data-server for profile // we've been given a new username, ask the data-server for profile
DataServerClient::getClientValueForKey(DataServerKey::UUID, username, this); DataServerClient::getValueForKeyAndUserString(DataServerKey::UUID, getUserString(), this);
DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL, username, this); DataServerClient::getValueForKeyAndUserString(DataServerKey::FaceMeshURL, getUserString(), this);
DataServerClient::getClientValueForKey(DataServerKey::SkeletonURL, username, this); DataServerClient::getValueForKeyAndUserString(DataServerKey::SkeletonURL, getUserString(), this);
// send our current domain server to the data-server // send our current domain server to the data-server
updateDomain(NodeList::getInstance()->getDomainHostname()); updateDomain(NodeList::getInstance()->getDomainHostname());
@ -70,7 +70,7 @@ void Profile::updateDomain(const QString& domain) {
_lastDomain = domain; _lastDomain = domain;
// send the changed domain to the data-server // send the changed domain to the data-server
DataServerClient::putValueForKeyAndUsername(DataServerKey::Domain, domain, _username); DataServerClient::putValueForKeyAndUserString(DataServerKey::Domain, domain, getUserString());
} }
} }
@ -99,8 +99,8 @@ void Profile::updatePosition(const glm::vec3 position) {
gettimeofday(&lastPositionSend, NULL); gettimeofday(&lastPositionSend, NULL);
// send the changed position to the data-server // send the changed position to the data-server
DataServerClient::putValueForKeyAndUsername(DataServerKey::Position, DataServerClient::putValueForKeyAndUserString(DataServerKey::Position,
QString(createByteArray(position)), _username); QString(createByteArray(position)), getUserString());
} }
} }
} }
@ -116,8 +116,8 @@ void Profile::updateOrientation(const glm::quat& orientation) {
uint64_t now = usecTimestampNow(); uint64_t now = usecTimestampNow();
if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS && if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS &&
glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) { glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) {
DataServerClient::putValueForKeyAndUsername(DataServerKey::Orientation, QString(createByteArray(eulerAngles)), DataServerClient::putValueForKeyAndUserString(DataServerKey::Orientation, QString(createByteArray(eulerAngles)),
_username); getUserString());
_lastOrientation = eulerAngles; _lastOrientation = eulerAngles;
_lastOrientationSend = now; _lastOrientationSend = now;

View file

@ -29,7 +29,7 @@ const HifiSockAddr& DataServerClient::dataServerSockAddr() {
return dsSockAddr; return dsSockAddr;
} }
void DataServerClient::putValueForKeyAndUsername(const QString& key, const QString& value, const QString& clientIdentifier) { void DataServerClient::putValueForKeyAndUserString(const QString& key, const QString& value, const QString& userString) {
unsigned char putPacket[MAX_PACKET_SIZE]; unsigned char putPacket[MAX_PACKET_SIZE];
// setup the header for this packet // setup the header for this packet
@ -40,8 +40,8 @@ void DataServerClient::putValueForKeyAndUsername(const QString& key, const QStri
numPacketBytes += sizeof(_sequenceNumber); numPacketBytes += sizeof(_sequenceNumber);
// pack the client UUID, null terminated // pack the client UUID, null terminated
memcpy(putPacket + numPacketBytes, qPrintable(clientIdentifier), clientIdentifier.toLocal8Bit().size()); memcpy(putPacket + numPacketBytes, qPrintable(userString), userString.size());
numPacketBytes += clientIdentifier.toLocal8Bit().size(); numPacketBytes += userString.size();
putPacket[numPacketBytes++] = '\0'; putPacket[numPacketBytes++] = '\0';
// pack a 1 to designate that we are putting a single value // pack a 1 to designate that we are putting a single value
@ -70,7 +70,7 @@ void DataServerClient::putValueForKeyAndUsername(const QString& key, const QStri
} }
void DataServerClient::putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid) { void DataServerClient::putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid) {
putValueForKeyAndUsername(key, value, uuidStringWithoutCurlyBraces(uuid)); putValueForKeyAndUserString(key, value, uuidStringWithoutCurlyBraces(uuid));
} }
void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid, DataServerCallbackObject* callbackObject) { void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid, DataServerCallbackObject* callbackObject) {
@ -79,13 +79,13 @@ void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uu
void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject) { void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject) {
if (!uuid.isNull()) { if (!uuid.isNull()) {
getValuesForKeysAndUsername(keys, uuidStringWithoutCurlyBraces(uuid), callbackObject); getValuesForKeysAndUserString(keys, uuidStringWithoutCurlyBraces(uuid), callbackObject);
} }
} }
void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, const QString& clientIdentifier, void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString,
DataServerCallbackObject* callbackObject) { DataServerCallbackObject* callbackObject) {
if (!clientIdentifier.isEmpty() && keys.size() <= UCHAR_MAX) { if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {
unsigned char getPacket[MAX_PACKET_SIZE]; unsigned char getPacket[MAX_PACKET_SIZE];
// setup the header for this packet // setup the header for this packet
@ -96,8 +96,8 @@ void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, cons
numPacketBytes += sizeof(_sequenceNumber); numPacketBytes += sizeof(_sequenceNumber);
// pack the user string (could be username or UUID string), null-terminate // pack the user string (could be username or UUID string), null-terminate
memcpy(getPacket + numPacketBytes, clientIdentifier.toLocal8Bit().constData(), clientIdentifier.size()); memcpy(getPacket + numPacketBytes, qPrintable(userString), userString.size());
numPacketBytes += clientIdentifier.size(); numPacketBytes += userString.size();
getPacket[numPacketBytes++] = '\0'; getPacket[numPacketBytes++] = '\0';
// pack one byte to designate the number of keys // pack one byte to designate the number of keys
@ -122,9 +122,9 @@ void DataServerClient::getValuesForKeysAndUsername(const QStringList& keys, cons
} }
} }
void DataServerClient::getClientValueForKey(const QString& key, const QString& clientIdentifier, void DataServerClient::getValueForKeyAndUserString(const QString& key, const QString& userString,
DataServerCallbackObject* callbackObject) { DataServerCallbackObject* callbackObject) {
getValuesForKeysAndUsername(QStringList(key), clientIdentifier, callbackObject); getValuesForKeysAndUserString(QStringList(key), userString, callbackObject);
} }
void DataServerClient::processConfirmFromDataServer(unsigned char* packetData) { void DataServerClient::processConfirmFromDataServer(unsigned char* packetData) {

View file

@ -26,15 +26,15 @@ class DataServerClient {
public: public:
static const HifiSockAddr& dataServerSockAddr(); static const HifiSockAddr& dataServerSockAddr();
static void putValueForKeyAndUsername(const QString& key, const QString& value, const QString& clientIdentifier); static void putValueForKeyAndUserString(const QString& key, const QString& value, const QString& userString);
static void putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid); static void putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid);
static void getClientValueForKey(const QString& key, const QString& _clientIdentifer, static void getValueForKeyAndUserString(const QString& key, const QString& userString,
DataServerCallbackObject* callbackObject); DataServerCallbackObject* callbackObject);
static void getValueForKeyAndUUID(const QString& key, const QUuid& uuid, DataServerCallbackObject* callbackObject); static void getValueForKeyAndUUID(const QString& key, const QUuid& uuid, DataServerCallbackObject* callbackObject);
static void getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject); static void getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid, DataServerCallbackObject* callbackObject);
static void getValuesForKeysAndUsername(const QStringList& keys, const QString& clientIdentifier, static void getValuesForKeysAndUserString(const QStringList& keys, const QString& userString,
DataServerCallbackObject* callbackObject); DataServerCallbackObject* callbackObject);
static void processMessageFromDataServer(unsigned char* packetData, int numPacketBytes); static void processMessageFromDataServer(unsigned char* packetData, int numPacketBytes);