From 7c797449ab29f9a938ce9088d4ee65fdb84ff820 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 30 Jun 2014 19:02:43 -0700 Subject: [PATCH] Comments + connectedDevice --- interface/src/Application.cpp | 10 +++++++--- interface/src/devices/OculusManager.cpp | 4 ++++ interface/src/devices/SixenseManager.cpp | 5 +++++ interface/src/devices/SixenseManager.h | 1 + libraries/networking/src/UserActivityLogger.cpp | 7 ++++--- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 702afd4dfe..9fcce81567 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -398,15 +398,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : } Application::~Application() { - int DELAI_TIME = 1000; + // In order to get the end of the session, we nned to give the account manager enough time to send the packet. QEventLoop loop; - QTimer timer; - connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + // Here we connect the callbacks to stop the event loop JSONCallbackParameters params; params.jsonCallbackReceiver = &loop; params.errorCallbackReceiver = &loop; params.jsonCallbackMethod = "quit"; params.errorCallbackMethod = "quit"; + // In case something goes wrong, we also setup a timer so that the delai is not greater than DELAI_TIME + int DELAI_TIME = 1000; + QTimer timer; + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + // Now we can log it UserActivityLogger::getInstance().close(params); timer.start(DELAI_TIME); loop.exec(); diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index b2ee4e8c18..6e17468bb5 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -14,6 +14,7 @@ #include #include +#include #include "Application.h" #include "OculusManager.h" @@ -45,6 +46,9 @@ void OculusManager::connect() { _hmdDevice = *_deviceManager->EnumerateDevices().CreateDevice(); if (_hmdDevice) { + if (!_isConnected) { + UserActivityLogger::getInstance().connectedDevice("hmd", "oculus"); + } _isConnected = true; _sensorDevice = *_hmdDevice->GetSensor(); diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index 558a82cd3d..1b7baf2ee1 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -40,6 +40,7 @@ SixenseManager::SixenseManager() { sixenseInit(); #endif + _hydrasConnected = false; _triggerPressed[0] = false; _bumperPressed[0] = false; _oldX[0] = -1; @@ -71,7 +72,11 @@ void SixenseManager::setFilter(bool filter) { void SixenseManager::update(float deltaTime) { #ifdef HAVE_SIXENSE if (sixenseGetNumActiveControllers() == 0) { + _hydrasConnected = false; return; + } else if (!_hydrasConnected) { + _hydrasConnected = true; + UserActivityLogger::getInstance().connectedDevice("spatial_controller", "hydra"); } MyAvatar* avatar = Application::getInstance()->getAvatar(); Hand* hand = avatar->getHand(); diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index 8803c2c006..8ca27ef77c 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -71,6 +71,7 @@ private: float _lastDistance; #endif + bool _hydrasConnected; quint64 _lastMovement; glm::vec3 _amountMoved; diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 1ad88bbca0..4a0b065c0a 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -28,12 +28,13 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall AccountManager& accountManager = AccountManager::getInstance(); QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType); + // Adding the action name QHttpPart actionPart; actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\""); actionPart.setBody(QByteArray().append(action)); multipart->append(actionPart); - + // If there are action details, add them to the multipart if (!details.isEmpty()) { QHttpPart detailsPart; detailsPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" @@ -41,9 +42,9 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall detailsPart.setBody(QJsonDocument(details).toJson(QJsonDocument::Compact)); multipart->append(detailsPart); } - qDebug() << "Loging activity" << action; - qDebug() << AccountManager::getInstance().getAuthURL() << ": " << AccountManager::getInstance().isLoggedIn(); + qDebug() << "Logging activity" << action; + // if no callbacks specified, call our owns if (params.isEmpty()) { params.jsonCallbackReceiver = this; params.jsonCallbackMethod = "requestFinished";