mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
replace DataServerClient and Profile with AccountManager
This commit is contained in:
parent
7c69028dc5
commit
c762b92e5a
16 changed files with 62 additions and 490 deletions
|
@ -33,7 +33,7 @@ const char* METAVOXEL_SERVER_CONFIG = "metavoxelServerConfig";
|
||||||
|
|
||||||
const quint16 DOMAIN_SERVER_HTTP_PORT = 8080;
|
const quint16 DOMAIN_SERVER_HTTP_PORT = 8080;
|
||||||
|
|
||||||
const QString DEFAULT_NODE_AUTH_HOSTNAME = "https://data.highfidelity.io";
|
const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io");
|
||||||
|
|
||||||
DomainServer::DomainServer(int argc, char* argv[]) :
|
DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
|
@ -41,7 +41,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
_staticAssignmentHash(),
|
_staticAssignmentHash(),
|
||||||
_assignmentQueue(),
|
_assignmentQueue(),
|
||||||
_hasCompletedRestartHold(false),
|
_hasCompletedRestartHold(false),
|
||||||
_nodeAuthenticationHostname(DEFAULT_NODE_AUTH_HOSTNAME)
|
_nodeAuthenticationHostname(DEFAULT_NODE_AUTH_URL)
|
||||||
{
|
{
|
||||||
const char CUSTOM_PORT_OPTION[] = "-p";
|
const char CUSTOM_PORT_OPTION[] = "-p";
|
||||||
const char* customPortString = getCmdOption(argc, (const char**) argv, CUSTOM_PORT_OPTION);
|
const char* customPortString = getCmdOption(argc, (const char**) argv, CUSTOM_PORT_OPTION);
|
||||||
|
@ -65,9 +65,9 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
const QString NO_AUTH_OPTION = "--noAuth";
|
const QString NO_AUTH_OPTION = "--noAuth";
|
||||||
const QString CUSTOM_AUTH_OPTION = "--customAuth";
|
const QString CUSTOM_AUTH_OPTION = "--customAuth";
|
||||||
if ((argumentIndex = argumentList.indexOf(NO_AUTH_OPTION) != -1)) {
|
if ((argumentIndex = argumentList.indexOf(NO_AUTH_OPTION) != -1)) {
|
||||||
_nodeAuthenticationHostname = QString();
|
_nodeAuthenticationHostname = QUrl();
|
||||||
} else if ((argumentIndex = argumentList.indexOf(CUSTOM_AUTH_OPTION)) != -1) {
|
} else if ((argumentIndex = argumentList.indexOf(CUSTOM_AUTH_OPTION)) != -1) {
|
||||||
_nodeAuthenticationHostname = argumentList.value(argumentIndex + 1);
|
_nodeAuthenticationHostname = QUrl(argumentList.value(argumentIndex + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::createInstance(NodeType::DomainServer, domainServerPort);
|
NodeList* nodeList = NodeList::createInstance(NodeType::DomainServer, domainServerPort);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
#include <QtCore/QQueue>
|
#include <QtCore/QQueue>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HTTPManager.h>
|
#include <HTTPManager.h>
|
||||||
|
@ -58,7 +59,7 @@ private:
|
||||||
|
|
||||||
bool _hasCompletedRestartHold;
|
bool _hasCompletedRestartHold;
|
||||||
|
|
||||||
QString _nodeAuthenticationHostname;
|
QUrl _nodeAuthenticationHostname;
|
||||||
private slots:
|
private slots:
|
||||||
void readAvailableDatagrams();
|
void readAvailableDatagrams();
|
||||||
void addStaticAssignmentsBackToQueueAfterRestart();
|
void addStaticAssignmentsBackToQueueAfterRestart();
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include <QXmlStreamAttributes>
|
#include <QXmlStreamAttributes>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
|
#include <AccountManager.h>
|
||||||
#include <AudioInjector.h>
|
#include <AudioInjector.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
#include <OctalCode.h>
|
#include <OctalCode.h>
|
||||||
|
@ -60,7 +61,6 @@
|
||||||
#include <VoxelSceneStats.h>
|
#include <VoxelSceneStats.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "DataServerClient.h"
|
|
||||||
#include "InterfaceVersion.h"
|
#include "InterfaceVersion.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "Swatch.h"
|
#include "Swatch.h"
|
||||||
|
@ -125,7 +125,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_wantToKillLocalVoxels(false),
|
_wantToKillLocalVoxels(false),
|
||||||
_audioScope(256, 200, true),
|
_audioScope(256, 200, true),
|
||||||
_myAvatar(),
|
_myAvatar(),
|
||||||
_profile(QString()),
|
|
||||||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||||
_mouseX(0),
|
_mouseX(0),
|
||||||
_mouseY(0),
|
_mouseY(0),
|
||||||
|
@ -650,13 +649,6 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum)
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resetProfile(const QString& username) {
|
|
||||||
// call the destructor on the old profile and construct a new one
|
|
||||||
(&_profile)->~Profile();
|
|
||||||
new (&_profile) Profile(username);
|
|
||||||
updateWindowTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
||||||
foreach(NodeType_t type, destinationNodeTypes) {
|
foreach(NodeType_t type, destinationNodeTypes) {
|
||||||
// Intercept data to voxel server when voxels are disabled
|
// Intercept data to voxel server when voxels are disabled
|
||||||
|
@ -1443,13 +1435,6 @@ void Application::timer() {
|
||||||
|
|
||||||
// ask the node list to check in with the domain server
|
// ask the node list to check in with the domain server
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
|
||||||
// send unmatched DataServerClient packets
|
|
||||||
DataServerClient::resendUnmatchedPackets();
|
|
||||||
|
|
||||||
// give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server
|
|
||||||
_profile.updatePosition(_myAvatar->getPosition());
|
|
||||||
_profile.updateOrientation(_myAvatar->getOrientation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static glm::vec3 getFaceVector(BoxFace face) {
|
static glm::vec3 getFaceVector(BoxFace face) {
|
||||||
|
@ -3828,7 +3813,7 @@ void Application::updateWindowTitle(){
|
||||||
QString buildVersion = " (build " + applicationVersion() + ")";
|
QString buildVersion = " (build " + applicationVersion() + ")";
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString()
|
QString title = QString() + nodeList->getSessionUUID().toString()
|
||||||
+ " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
|
+ " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
|
||||||
|
|
||||||
qDebug("Application title set to: %s", title.toStdString().c_str());
|
qDebug("Application title set to: %s", title.toStdString().c_str());
|
||||||
|
@ -3836,9 +3821,6 @@ void Application::updateWindowTitle(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::domainChanged(const QString& domainHostname) {
|
void Application::domainChanged(const QString& domainHostname) {
|
||||||
// update the user's last domain in their Profile (which will propagate to data-server)
|
|
||||||
_profile.updateDomain(domainHostname);
|
|
||||||
|
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
|
|
||||||
// reset the environment so that we don't erroneously end up with multiple
|
// reset the environment so that we don't erroneously end up with multiple
|
||||||
|
@ -4234,6 +4216,6 @@ void Application::takeSnapshot() {
|
||||||
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
||||||
player->play();
|
player->play();
|
||||||
|
|
||||||
Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition());
|
Snapshot::saveSnapshot(_glWidget, AccountManager::getUsername(), _myAvatar->getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
#include "avatar/Avatar.h"
|
#include "avatar/Avatar.h"
|
||||||
#include "avatar/AvatarManager.h"
|
#include "avatar/AvatarManager.h"
|
||||||
#include "avatar/MyAvatar.h"
|
#include "avatar/MyAvatar.h"
|
||||||
#include "avatar/Profile.h"
|
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
#include "devices/SixenseManager.h"
|
#include "devices/SixenseManager.h"
|
||||||
#include "renderer/AmbientOcclusionEffect.h"
|
#include "renderer/AmbientOcclusionEffect.h"
|
||||||
|
@ -173,7 +172,6 @@ public:
|
||||||
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||||
|
|
||||||
AvatarManager& getAvatarManager() { return _avatarManager; }
|
AvatarManager& getAvatarManager() { return _avatarManager; }
|
||||||
Profile* getProfile() { return &_profile; }
|
|
||||||
void resetProfile(const QString& username);
|
void resetProfile(const QString& username);
|
||||||
|
|
||||||
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
||||||
|
@ -376,7 +374,6 @@ private:
|
||||||
|
|
||||||
AvatarManager _avatarManager;
|
AvatarManager _avatarManager;
|
||||||
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)
|
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)
|
||||||
Profile _profile; // The data-server linked profile for this user
|
|
||||||
|
|
||||||
Faceshift _faceshift;
|
Faceshift _faceshift;
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,6 @@ void DatagramProcessor::processDatagrams() {
|
||||||
application->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(incomingPacket.size());
|
application->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(incomingPacket.size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketTypeDataServerGet:
|
|
||||||
case PacketTypeDataServerPut:
|
|
||||||
case PacketTypeDataServerSend:
|
|
||||||
case PacketTypeDataServerConfirm:
|
|
||||||
DataServerClient::processMessageFromDataServer(incomingPacket);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
nodeList->processNodeData(senderSockAddr, incomingPacket);
|
nodeList->processNodeData(senderSockAddr, incomingPacket);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "DataServerClient.h"
|
|
||||||
#include "PairingHandler.h"
|
#include "PairingHandler.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
@ -511,7 +510,6 @@ void Menu::loadSettings(QSettings* settings) {
|
||||||
scanMenuBar(&loadAction, settings);
|
scanMenuBar(&loadAction, settings);
|
||||||
Application::getInstance()->getAvatar()->loadData(settings);
|
Application::getInstance()->getAvatar()->loadData(settings);
|
||||||
Application::getInstance()->getSwatch()->loadData(settings);
|
Application::getInstance()->getSwatch()->loadData(settings);
|
||||||
Application::getInstance()->getProfile()->loadData(settings);
|
|
||||||
Application::getInstance()->updateWindowTitle();
|
Application::getInstance()->updateWindowTitle();
|
||||||
NodeList::getInstance()->loadData(settings);
|
NodeList::getInstance()->loadData(settings);
|
||||||
|
|
||||||
|
@ -544,7 +542,6 @@ void Menu::saveSettings(QSettings* settings) {
|
||||||
scanMenuBar(&saveAction, settings);
|
scanMenuBar(&saveAction, settings);
|
||||||
Application::getInstance()->getAvatar()->saveData(settings);
|
Application::getInstance()->getAvatar()->saveData(settings);
|
||||||
Application::getInstance()->getSwatch()->saveData(settings);
|
Application::getInstance()->getSwatch()->saveData(settings);
|
||||||
Application::getInstance()->getProfile()->saveData(settings);
|
|
||||||
NodeList::getInstance()->saveData(settings);
|
NodeList::getInstance()->saveData(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,7 +741,7 @@ void Menu::login() {
|
||||||
QInputDialog loginDialog(Application::getInstance()->getWindow());
|
QInputDialog loginDialog(Application::getInstance()->getWindow());
|
||||||
loginDialog.setWindowTitle("Login");
|
loginDialog.setWindowTitle("Login");
|
||||||
loginDialog.setLabelText("Username:");
|
loginDialog.setLabelText("Username:");
|
||||||
QString username = Application::getInstance()->getProfile()->getUsername();
|
QString username = QString();
|
||||||
loginDialog.setTextValue(username);
|
loginDialog.setTextValue(username);
|
||||||
loginDialog.setWindowFlags(Qt::Sheet);
|
loginDialog.setWindowFlags(Qt::Sheet);
|
||||||
loginDialog.resize(loginDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, loginDialog.size().height());
|
loginDialog.resize(loginDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, loginDialog.size().height());
|
||||||
|
@ -753,9 +750,6 @@ void Menu::login() {
|
||||||
|
|
||||||
if (dialogReturn == QDialog::Accepted && !loginDialog.textValue().isEmpty() && loginDialog.textValue() != username) {
|
if (dialogReturn == QDialog::Accepted && !loginDialog.textValue().isEmpty() && loginDialog.textValue() != username) {
|
||||||
// there has been a username change
|
// there has been a username change
|
||||||
// ask for a profile reset with the new username
|
|
||||||
Application::getInstance()->resetProfile(loginDialog.textValue());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFakeEnterEvent();
|
sendFakeEnterEvent();
|
||||||
|
@ -997,7 +991,7 @@ void Menu::goTo() {
|
||||||
QInputDialog gotoDialog(Application::getInstance()->getWindow());
|
QInputDialog gotoDialog(Application::getInstance()->getWindow());
|
||||||
gotoDialog.setWindowTitle("Go to");
|
gotoDialog.setWindowTitle("Go to");
|
||||||
gotoDialog.setLabelText("Destination:");
|
gotoDialog.setLabelText("Destination:");
|
||||||
QString destination = Application::getInstance()->getProfile()->getUsername();
|
QString destination = QString();
|
||||||
gotoDialog.setTextValue(destination);
|
gotoDialog.setTextValue(destination);
|
||||||
gotoDialog.setWindowFlags(Qt::Sheet);
|
gotoDialog.setWindowFlags(Qt::Sheet);
|
||||||
gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
|
gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
|
||||||
|
@ -1010,12 +1004,6 @@ void Menu::goTo() {
|
||||||
// go to coordinate destination or to Username
|
// go to coordinate destination or to Username
|
||||||
if (!goToDestination(destination)) {
|
if (!goToDestination(destination)) {
|
||||||
// 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::getValuesForKeysAndUserString(
|
|
||||||
QStringList()
|
|
||||||
<< DataServerKey::Domain
|
|
||||||
<< DataServerKey::Position
|
|
||||||
<< DataServerKey::Orientation,
|
|
||||||
destination, Application::getInstance()->getProfile());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
#include "DataServerClient.h"
|
|
||||||
#include "Hand.h"
|
#include "Hand.h"
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
#include <AvatarHashMap.h>
|
#include <AvatarHashMap.h>
|
||||||
#include <DataServerClient.h>
|
|
||||||
|
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
#include "DataServerClient.h"
|
|
||||||
#include "Environment.h"
|
#include "Environment.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "MyAvatar.h"
|
#include "MyAvatar.h"
|
||||||
|
|
|
@ -1,167 +0,0 @@
|
||||||
//
|
|
||||||
// Profile.cpp
|
|
||||||
// hifi
|
|
||||||
//
|
|
||||||
// Created by Stephen Birarda on 10/8/13.
|
|
||||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QtCore/QSettings>
|
|
||||||
|
|
||||||
#include <NodeList.h>
|
|
||||||
#include <UUID.h>
|
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "Profile.h"
|
|
||||||
#include "Util.h"
|
|
||||||
|
|
||||||
Profile::Profile(const QString &username) :
|
|
||||||
_username(),
|
|
||||||
_uuid(),
|
|
||||||
_lastDomain(),
|
|
||||||
_lastPosition(0.0, 0.0, 0.0),
|
|
||||||
_lastOrientationSend(0)
|
|
||||||
{
|
|
||||||
if (!username.isEmpty()) {
|
|
||||||
setUsername(username);
|
|
||||||
|
|
||||||
// we've been given a new username, ask the data-server for profile
|
|
||||||
DataServerClient::getValueForKeyAndUserString(DataServerKey::UUID, getUserString(), this);
|
|
||||||
|
|
||||||
// send our current domain server to the data-server
|
|
||||||
updateDomain(NodeList::getInstance()->getDomainInfo().getHostname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Profile::getUserString() const {
|
|
||||||
if (_uuid.isNull()) {
|
|
||||||
return _username;
|
|
||||||
} else {
|
|
||||||
return uuidStringWithoutCurlyBraces(_uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::updateDomain(const QString& domain) {
|
|
||||||
if (_lastDomain != domain) {
|
|
||||||
_lastDomain = domain;
|
|
||||||
|
|
||||||
// send the changed domain to the data-server
|
|
||||||
DataServerClient::putValueForKeyAndUserString(DataServerKey::Domain, domain, getUserString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static QByteArray createByteArray(const glm::vec3& vector) {
|
|
||||||
return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::updatePosition(const glm::vec3 position) {
|
|
||||||
if (_lastPosition != position) {
|
|
||||||
|
|
||||||
static timeval lastPositionSend = {};
|
|
||||||
const quint64 DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000;
|
|
||||||
const float DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS = 1;
|
|
||||||
|
|
||||||
if (usecTimestampNow() - usecTimestamp(&lastPositionSend) >= DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS &&
|
|
||||||
(fabsf(_lastPosition.x - position.x) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS ||
|
|
||||||
fabsf(_lastPosition.y - position.y) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS ||
|
|
||||||
fabsf(_lastPosition.z - position.z) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS)) {
|
|
||||||
|
|
||||||
// if it has been 5 seconds since the last position change and the user has moved >= the threshold
|
|
||||||
// in at least one of the axis then send the position update to the data-server
|
|
||||||
|
|
||||||
_lastPosition = position;
|
|
||||||
|
|
||||||
// update the lastPositionSend to now
|
|
||||||
gettimeofday(&lastPositionSend, NULL);
|
|
||||||
|
|
||||||
// send the changed position to the data-server
|
|
||||||
DataServerClient::putValueForKeyAndUserString(DataServerKey::Position,
|
|
||||||
QString(createByteArray(position)), getUserString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::updateOrientation(const glm::quat& orientation) {
|
|
||||||
glm::vec3 eulerAngles = safeEulerAngles(orientation);
|
|
||||||
if (_lastOrientation == eulerAngles) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const quint64 DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000;
|
|
||||||
const float DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES = 5.0f;
|
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
|
||||||
if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS &&
|
|
||||||
glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) {
|
|
||||||
DataServerClient::putValueForKeyAndUserString(DataServerKey::Orientation, QString(createByteArray(eulerAngles)),
|
|
||||||
getUserString());
|
|
||||||
|
|
||||||
_lastOrientation = eulerAngles;
|
|
||||||
_lastOrientationSend = now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::saveData(QSettings* settings) {
|
|
||||||
settings->beginGroup("Profile");
|
|
||||||
|
|
||||||
settings->setValue("username", _username);
|
|
||||||
settings->setValue("UUID", _uuid);
|
|
||||||
|
|
||||||
settings->endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::loadData(QSettings* settings) {
|
|
||||||
settings->beginGroup("Profile");
|
|
||||||
|
|
||||||
setUsername(settings->value("username").toString());
|
|
||||||
this->setUUID(settings->value("UUID").toUuid());
|
|
||||||
|
|
||||||
settings->endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::processDataServerResponse(const QString& userString, const QStringList& keyList, const QStringList& valueList) {
|
|
||||||
for (int i = 0; i < keyList.size(); i++) {
|
|
||||||
if (valueList[i] != " ") {
|
|
||||||
if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&
|
|
||||||
keyList[i + 2] == DataServerKey::Orientation && valueList[i] != " " &&
|
|
||||||
valueList[i + 1] != " " && valueList[i + 2] != " ") {
|
|
||||||
|
|
||||||
QStringList coordinateItems = valueList[i + 1].split(',');
|
|
||||||
QStringList orientationItems = valueList[i + 2].split(',');
|
|
||||||
|
|
||||||
if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
|
|
||||||
|
|
||||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
|
||||||
MyAvatar::sendKillAvatar();
|
|
||||||
|
|
||||||
qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
|
|
||||||
", position to" << valueList[i + 1].toLocal8Bit().constData() <<
|
|
||||||
", and orientation to" << valueList[i + 2].toLocal8Bit().constData() <<
|
|
||||||
"to go to" << userString;
|
|
||||||
|
|
||||||
NodeList::getInstance()->getDomainInfo().setHostname(valueList[i]);
|
|
||||||
// orient the user to face the target
|
|
||||||
glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
|
|
||||||
orientationItems[1].toFloat(),
|
|
||||||
orientationItems[2].toFloat()))) *
|
|
||||||
glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
|
|
||||||
Application::getInstance()->getAvatar()->setOrientation(newOrientation);
|
|
||||||
|
|
||||||
// move the user a couple units away
|
|
||||||
const float DISTANCE_TO_USER = 2.0f;
|
|
||||||
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
|
|
||||||
coordinateItems[2].toFloat()
|
|
||||||
) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
|
||||||
Application::getInstance()->getAvatar()->setPosition(newPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (keyList[i] == DataServerKey::UUID) {
|
|
||||||
// this is the user's UUID - set it on the profile
|
|
||||||
setUUID(QUuid(valueList[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::setUsername(const QString& username) {
|
|
||||||
_username = username;
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
//
|
|
||||||
// Profile.h
|
|
||||||
// hifi
|
|
||||||
//
|
|
||||||
// Created by Stephen Birarda on 10/8/13.
|
|
||||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __hifi__Profile__
|
|
||||||
#define __hifi__Profile__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QUrl>
|
|
||||||
#include <QtCore/QUuid>
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
|
||||||
|
|
||||||
#include "DataServerClient.h"
|
|
||||||
|
|
||||||
class Profile : public DataServerCallbackObject {
|
|
||||||
public:
|
|
||||||
Profile(const QString& username);
|
|
||||||
|
|
||||||
QString getUserString() const;
|
|
||||||
|
|
||||||
const QString& getUsername() const { return _username; }
|
|
||||||
|
|
||||||
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
|
||||||
const QUuid& getUUID() { return _uuid; }
|
|
||||||
|
|
||||||
void updateDomain(const QString& domain);
|
|
||||||
void updatePosition(const glm::vec3 position);
|
|
||||||
void updateOrientation(const glm::quat& orientation);
|
|
||||||
|
|
||||||
QString getLastDomain() const { return _lastDomain; }
|
|
||||||
const glm::vec3& getLastPosition() const { return _lastPosition; }
|
|
||||||
|
|
||||||
void saveData(QSettings* settings);
|
|
||||||
void loadData(QSettings* settings);
|
|
||||||
|
|
||||||
void processDataServerResponse(const QString& userString, const QStringList& keyList, const QStringList& valueList);
|
|
||||||
private:
|
|
||||||
|
|
||||||
void setUsername(const QString& username);
|
|
||||||
|
|
||||||
QString _username;
|
|
||||||
QUuid _uuid;
|
|
||||||
QString _lastDomain;
|
|
||||||
glm::vec3 _lastPosition;
|
|
||||||
glm::vec3 _lastOrientation;
|
|
||||||
quint64 _lastOrientationSend;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* defined(__hifi__Profile__) */
|
|
27
libraries/shared/src/AccountManager.cpp
Normal file
27
libraries/shared/src/AccountManager.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// AccountManager.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/18/2014.
|
||||||
|
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QtCore/QDataStream>
|
||||||
|
|
||||||
|
#include "PacketHeaders.h"
|
||||||
|
|
||||||
|
#include "AccountManager.h"
|
||||||
|
|
||||||
|
QString AccountManager::_username = "";
|
||||||
|
|
||||||
|
void AccountManager::processDomainServerAuthRequest(const QByteArray& packet) {
|
||||||
|
QDataStream authPacketStream(packet);
|
||||||
|
authPacketStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
|
// grab the hostname this domain-server wants us to authenticate with
|
||||||
|
QString authenticationHostname;
|
||||||
|
authPacketStream >> authenticationHostname;
|
||||||
|
|
||||||
|
// check if we already have an access token associated with that hostname
|
||||||
|
|
||||||
|
}
|
24
libraries/shared/src/AccountManager.h
Normal file
24
libraries/shared/src/AccountManager.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// AccountManager.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/18/2014.
|
||||||
|
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __hifi__AccountManager__
|
||||||
|
#define __hifi__AccountManager__
|
||||||
|
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
|
class AccountManager {
|
||||||
|
public:
|
||||||
|
static void processDomainServerAuthRequest(const QByteArray& packet);
|
||||||
|
|
||||||
|
static const QString& getUsername() { return _username; }
|
||||||
|
static void setUsername(const QString& username) { _username = username; }
|
||||||
|
private:
|
||||||
|
static QString _username;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__AccountManager__) */
|
|
@ -1,148 +0,0 @@
|
||||||
//
|
|
||||||
// DataServerClient.cpp
|
|
||||||
// hifi
|
|
||||||
//
|
|
||||||
// Created by Stephen Birarda on 10/7/13.
|
|
||||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QtCore/QUrl>
|
|
||||||
#include <QtNetwork/QUdpSocket>
|
|
||||||
|
|
||||||
#include "NodeList.h"
|
|
||||||
#include "PacketHeaders.h"
|
|
||||||
#include "UUID.h"
|
|
||||||
|
|
||||||
#include "DataServerClient.h"
|
|
||||||
|
|
||||||
QMap<quint8, QByteArray> DataServerClient::_unmatchedPackets;
|
|
||||||
QMap<quint8, DataServerCallbackObject*> DataServerClient::_callbackObjects;
|
|
||||||
quint8 DataServerClient::_sequenceNumber = 0;
|
|
||||||
|
|
||||||
const char MULTI_KEY_VALUE_SEPARATOR = '|';
|
|
||||||
|
|
||||||
const char DATA_SERVER_HOSTNAME[] = "data.highfidelity.io";
|
|
||||||
const unsigned short DATA_SERVER_PORT = 3282;
|
|
||||||
|
|
||||||
const HifiSockAddr& DataServerClient::dataServerSockAddr() {
|
|
||||||
static HifiSockAddr dsSockAddr = HifiSockAddr(DATA_SERVER_HOSTNAME, DATA_SERVER_PORT);
|
|
||||||
return dsSockAddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::putValueForKeyAndUserString(const QString& key, const QString& value, const QString& userString) {
|
|
||||||
// setup the header for this packet and push packetStream to desired spot
|
|
||||||
QByteArray putPacket = byteArrayWithPopluatedHeader(PacketTypeDataServerPut);
|
|
||||||
QDataStream packetStream(&putPacket, QIODevice::Append);
|
|
||||||
|
|
||||||
// pack our data for the put packet
|
|
||||||
packetStream << _sequenceNumber << userString << key << value;
|
|
||||||
|
|
||||||
// add the putPacket to our vector of unconfirmed packets, will be deleted once put is confirmed
|
|
||||||
_unmatchedPackets.insert(_sequenceNumber, putPacket);
|
|
||||||
|
|
||||||
// send this put request to the data server
|
|
||||||
NodeList::getInstance()->getNodeSocket().writeDatagram(putPacket, dataServerSockAddr().getAddress(),
|
|
||||||
dataServerSockAddr().getPort());
|
|
||||||
|
|
||||||
// push the sequence number forwards
|
|
||||||
_sequenceNumber++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::putValueForKeyAndUUID(const QString& key, const QString& value, const QUuid& uuid) {
|
|
||||||
putValueForKeyAndUserString(key, value, uuidStringWithoutCurlyBraces(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::getValueForKeyAndUUID(const QString& key, const QUuid &uuid, DataServerCallbackObject* callbackObject) {
|
|
||||||
getValuesForKeysAndUUID(QStringList(key), uuid, callbackObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::getValuesForKeysAndUUID(const QStringList& keys, const QUuid& uuid,
|
|
||||||
DataServerCallbackObject* callbackObject) {
|
|
||||||
if (!uuid.isNull()) {
|
|
||||||
getValuesForKeysAndUserString(keys, uuidStringWithoutCurlyBraces(uuid), callbackObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::getValuesForKeysAndUserString(const QStringList& keys, const QString& userString,
|
|
||||||
DataServerCallbackObject* callbackObject) {
|
|
||||||
if (!userString.isEmpty() && keys.size() <= UCHAR_MAX) {
|
|
||||||
QByteArray getPacket = byteArrayWithPopluatedHeader(PacketTypeDataServerGet);
|
|
||||||
QDataStream packetStream(&getPacket, QIODevice::Append);
|
|
||||||
|
|
||||||
// pack our data for the getPacket
|
|
||||||
packetStream << _sequenceNumber << userString << keys.join(MULTI_KEY_VALUE_SEPARATOR);
|
|
||||||
|
|
||||||
// add the getPacket to our map of unconfirmed packets, will be deleted once we get a response from the nameserver
|
|
||||||
_unmatchedPackets.insert(_sequenceNumber, getPacket);
|
|
||||||
_callbackObjects.insert(_sequenceNumber, callbackObject);
|
|
||||||
|
|
||||||
// send the get to the data server
|
|
||||||
NodeList::getInstance()->getNodeSocket().writeDatagram(getPacket, dataServerSockAddr().getAddress(),
|
|
||||||
dataServerSockAddr().getPort());
|
|
||||||
_sequenceNumber++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::getValueForKeyAndUserString(const QString& key, const QString& userString,
|
|
||||||
DataServerCallbackObject* callbackObject) {
|
|
||||||
getValuesForKeysAndUserString(QStringList(key), userString, callbackObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::processConfirmFromDataServer(const QByteArray& packet) {
|
|
||||||
removeMatchedPacketFromMap(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::processSendFromDataServer(const QByteArray& packet) {
|
|
||||||
// pull the user string from the packet so we know who to associate this with
|
|
||||||
QDataStream packetStream(packet);
|
|
||||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
|
||||||
|
|
||||||
quint8 sequenceNumber = 0;
|
|
||||||
packetStream >> sequenceNumber;
|
|
||||||
|
|
||||||
if (_callbackObjects.find(sequenceNumber) != _callbackObjects.end()) {
|
|
||||||
// remove the packet from our two maps, it's matched
|
|
||||||
DataServerCallbackObject* callbackObject = _callbackObjects.take(sequenceNumber);
|
|
||||||
_unmatchedPackets.remove(sequenceNumber);
|
|
||||||
|
|
||||||
QString userString, keyListString, valueListString;
|
|
||||||
|
|
||||||
packetStream >> userString >> keyListString >> valueListString;
|
|
||||||
|
|
||||||
callbackObject->processDataServerResponse(userString, keyListString.split(MULTI_KEY_VALUE_SEPARATOR),
|
|
||||||
valueListString.split(MULTI_KEY_VALUE_SEPARATOR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::processMessageFromDataServer(const QByteArray& packet) {
|
|
||||||
switch (packetTypeForPacket(packet)) {
|
|
||||||
case PacketTypeDataServerSend:
|
|
||||||
processSendFromDataServer(packet);
|
|
||||||
break;
|
|
||||||
case PacketTypeDataServerConfirm:
|
|
||||||
processConfirmFromDataServer(packet);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::removeMatchedPacketFromMap(const QByteArray& packet) {
|
|
||||||
quint8 sequenceNumber = packet[numBytesForPacketHeader(packet)];
|
|
||||||
|
|
||||||
// attempt to remove a packet with this sequence number from the QMap of unmatched packets
|
|
||||||
_unmatchedPackets.remove(sequenceNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataServerClient::resendUnmatchedPackets() {
|
|
||||||
if (_unmatchedPackets.size() > 0) {
|
|
||||||
qDebug() << "Resending" << _unmatchedPackets.size() << "packets to the data server.";
|
|
||||||
|
|
||||||
foreach (const QByteArray& packet, _unmatchedPackets) {
|
|
||||||
// send the unmatched packet to the data server
|
|
||||||
NodeList::getInstance()->getNodeSocket().writeDatagram(packet.data(), packet.size(),
|
|
||||||
dataServerSockAddr().getAddress(),
|
|
||||||
dataServerSockAddr().getPort());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
//
|
|
||||||
// DataServerClient.h
|
|
||||||
// hifi
|
|
||||||
//
|
|
||||||
// Created by Stephen Birarda on 10/7/13.
|
|
||||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __hifi__DataServerClient__
|
|
||||||
#define __hifi__DataServerClient__
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QPointer>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QUuid>
|
|
||||||
|
|
||||||
#include "HifiSockAddr.h"
|
|
||||||
|
|
||||||
class DataServerCallbackObject {
|
|
||||||
public:
|
|
||||||
virtual void processDataServerResponse(const QString& userString, const QStringList& keyList, const QStringList& valueList) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DataServerClient {
|
|
||||||
public:
|
|
||||||
static const HifiSockAddr& dataServerSockAddr();
|
|
||||||
|
|
||||||
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 getValueForKeyAndUserString(const QString& key, const QString& userString,
|
|
||||||
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 getValuesForKeysAndUserString(const QStringList& keys, const QString& userString,
|
|
||||||
DataServerCallbackObject* callbackObject);
|
|
||||||
|
|
||||||
static void processMessageFromDataServer(const QByteArray& packet);
|
|
||||||
|
|
||||||
static void resendUnmatchedPackets();
|
|
||||||
private:
|
|
||||||
static void processConfirmFromDataServer(const QByteArray& packet);
|
|
||||||
static void processSendFromDataServer(const QByteArray& packet);
|
|
||||||
static void removeMatchedPacketFromMap(const QByteArray& packet);
|
|
||||||
|
|
||||||
static QMap<quint8, QByteArray> _unmatchedPackets;
|
|
||||||
static QMap<quint8, DataServerCallbackObject*> _callbackObjects;
|
|
||||||
static quint8 _sequenceNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace DataServerKey {
|
|
||||||
const QString Domain = "domain";
|
|
||||||
const QString Position = "position";
|
|
||||||
const QString Orientation = "orientation";
|
|
||||||
const QString UUID = "uuid";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* defined(__hifi__DataServerClient__) */
|
|
|
@ -197,13 +197,7 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
||||||
}
|
}
|
||||||
case PacketTypeDomainServerAuthRequest: {
|
case PacketTypeDomainServerAuthRequest: {
|
||||||
// the domain-server has asked us to auth via a data-server
|
// the domain-server has asked us to auth via a data-server
|
||||||
QDataStream authPacketStream(packet);
|
|
||||||
authPacketStream.skipRawData(numBytesForPacketHeader(packet));
|
|
||||||
|
|
||||||
QString authenticationHostname;
|
|
||||||
authPacketStream >> authenticationHostname;
|
|
||||||
|
|
||||||
qDebug() << "Domain server wants us to auth with" << authenticationHostname;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue