use NodeList ownerUUID for DataServerScriptingInterface, fix double UUID send

This commit is contained in:
Stephen Birarda 2014-01-22 12:00:26 -08:00
parent d57aec9793
commit a9ce6c7467
5 changed files with 7 additions and 19 deletions

View file

@ -2494,17 +2494,14 @@ void Application::updateAvatar(float deltaTime) {
// Get audio loudness data from audio input device
_myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness());
NodeList* nodeList = NodeList::getInstance();
// send head/hand data to the avatar mixer and voxel server
unsigned char broadcastString[MAX_PACKET_SIZE];
unsigned char* endOfBroadcastStringWrite = broadcastString;
endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA);
QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
memcpy(endOfBroadcastStringWrite, ownerUUID.constData(), ownerUUID.size());
endOfBroadcastStringWrite += ownerUUID.size();
// pack the NodeList owner UUID
endOfBroadcastStringWrite += NodeList::getInstance()->packOwnerUUID(endOfBroadcastStringWrite);
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);

View file

@ -68,9 +68,6 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
_handData = new HandData(this);
}
// pack the NodeList owner UUID
destinationBuffer += NodeList::getInstance()->packOwnerUUID(destinationBuffer);
// Body world position
memcpy(destinationBuffer, &_position, sizeof(float) * 3);
destinationBuffer += sizeof(float) * 3;

View file

@ -7,15 +7,15 @@
//
#include <DataServerClient.h>
#include <NodeList.h>
#include "DataServerScriptingInterface.h"
DataServerScriptingInterface::DataServerScriptingInterface() :
_uuid(QUuid::createUuid())
DataServerScriptingInterface::DataServerScriptingInterface()
{
}
void DataServerScriptingInterface::setValueForKey(const QString& key, const QString& value) {
DataServerClient::putValueForKeyAndUUID(key, value, _uuid);
DataServerClient::putValueForKeyAndUUID(key, value, NodeList::getInstance()->getOwnerUUID());
}

View file

@ -18,13 +18,8 @@ class DataServerScriptingInterface : public QObject {
public:
DataServerScriptingInterface();
void refreshUUID() { _uuid = QUuid::createUuid(); }
const QUuid& getUUID() const { return _uuid; }
public slots:
void setValueForKey(const QString& key, const QString& value);
private:
QUuid _uuid;
};
#endif /* defined(__hifi__DataServerScriptingInterface__) */

View file

@ -41,6 +41,7 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
AbstractControllerScriptingInterface* controllerScriptingInterface) :
_dataServerScriptingInterface(),
_avatarData(NULL)
{
_scriptContents = scriptContents;
@ -249,9 +250,7 @@ void ScriptEngine::run() {
numAvatarHeaderBytes = populateTypeAndVersion(avatarPacket, PACKET_TYPE_HEAD_DATA);
// pack the owner UUID for this script
QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
memcpy(avatarPacket + numAvatarHeaderBytes, ownerUUID.constData(), ownerUUID.size());
numAvatarHeaderBytes += ownerUUID.size();
numAvatarHeaderBytes += NodeList::getInstance()->packOwnerUUID(avatarPacket);
}
int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes;