mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
HoloLens: Added support for session pin code and bearer authentication. Improved session management and error handling. Added some dignostic timings for sending of array data.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicHoloLensSession.h"
|
||||
#include "RicHoloLensSessionManager.h"
|
||||
#include "RicHoloLensSessionObserver.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <QDir>
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
@@ -45,6 +44,7 @@
|
||||
RicHoloLensSession::RicHoloLensSession()
|
||||
: m_isSessionValid(false),
|
||||
m_lastExtractionMetaDataSequenceNumber(-1),
|
||||
m_sessionObserver(nullptr),
|
||||
m_dbgEnableFileExport(false)
|
||||
{
|
||||
}
|
||||
@@ -60,12 +60,14 @@ RicHoloLensSession::~RicHoloLensSession()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicHoloLensSession* RicHoloLensSession::createSession(const QString& serverUrl, const QString& sessionName)
|
||||
RicHoloLensSession* RicHoloLensSession::createSession(const QString& serverUrl, const QString& sessionName, const QByteArray& sessionPinCode, RicHoloLensSessionObserver* sessionObserver)
|
||||
{
|
||||
RicHoloLensSession* newSession = new RicHoloLensSession;
|
||||
|
||||
newSession->m_restClient = new RicHoloLensRestClient(serverUrl, sessionName, newSession);
|
||||
newSession->m_restClient->createSession();
|
||||
newSession->m_restClient->createSession(sessionPinCode);
|
||||
|
||||
newSession->m_sessionObserver = sessionObserver;
|
||||
|
||||
// For now, leave this on!!!
|
||||
// We probably want to export this as a preference parameter
|
||||
@@ -127,22 +129,29 @@ void RicHoloLensSession::updateSessionDataFromView(const RimGridView& activeView
|
||||
{
|
||||
RiaLogging::info("HoloLens: Updating visualization data");
|
||||
|
||||
QString modelMetaJsonStr;
|
||||
std::vector<int> allReferencedPacketIds;
|
||||
// Note
|
||||
// Currently we clear the packet directory each time we update the visualization data
|
||||
// This means we do no caching of actual packet data and we assume that the server will ask for data
|
||||
// packets/arrays right after having received updated meta data
|
||||
m_packetDirectory.clear();
|
||||
|
||||
VdeVizDataExtractor extractor(activeView);
|
||||
|
||||
QString modelMetaJsonStr;
|
||||
std::vector<int> allReferencedPacketIds;
|
||||
extractor.extractViewContents(&modelMetaJsonStr, &allReferencedPacketIds, &m_packetDirectory);
|
||||
|
||||
m_lastExtractionMetaDataSequenceNumber++;
|
||||
m_lastExtractionAllReferencedPacketIdsArr = allReferencedPacketIds;
|
||||
|
||||
|
||||
if (m_restClient)
|
||||
{
|
||||
RiaLogging::info(QString("HoloLens: Sending updated meta data to sharing server (sequenceNumber=%1)").arg(m_lastExtractionMetaDataSequenceNumber));
|
||||
m_restClient->sendMetaData(m_lastExtractionMetaDataSequenceNumber, modelMetaJsonStr);
|
||||
}
|
||||
|
||||
|
||||
// Debug export to file
|
||||
if (m_dbgEnableFileExport)
|
||||
{
|
||||
@@ -181,15 +190,24 @@ void RicHoloLensSession::handleSuccessfulCreateSession()
|
||||
RiaLogging::info("HoloLens: Session successfully created");
|
||||
m_isSessionValid = true;
|
||||
|
||||
// Slight hack here - reaching out to the manager to update GUI
|
||||
// We should really just be notifying the manager that our state has changed
|
||||
RicHoloLensSessionManager::refreshToolbarState();
|
||||
notifyObserver(RicHoloLensSessionObserver::CreateSessionSucceeded);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensSession::handleFailedCreateSession()
|
||||
{
|
||||
RiaLogging::error("HoloLens: Failed to create session");
|
||||
m_isSessionValid = false;
|
||||
|
||||
notifyObserver(RicHoloLensSessionObserver::CreateSessionFailed);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Handle the server response we receive after sending new meta data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensSession::handleSuccessfulSendMetaData(int metaDataSequenceNumber)
|
||||
void RicHoloLensSession::handleSuccessfulSendMetaData(int metaDataSequenceNumber, const QByteArray& /*jsonServerResponseString*/)
|
||||
{
|
||||
RiaLogging::info(QString("HoloLens: Processing server response to meta data (sequenceNumber=%1)").arg(metaDataSequenceNumber));
|
||||
|
||||
@@ -229,5 +247,19 @@ void RicHoloLensSession::handleError(const QString& errMsg, const QString& url,
|
||||
fullMsg += "\n url: " + url;
|
||||
|
||||
RiaLogging::error(fullMsg);
|
||||
|
||||
// It is probably not correct to always consider an error a state change, but for now
|
||||
notifyObserver(RicHoloLensSessionObserver::GeneralError);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicHoloLensSession::notifyObserver(RicHoloLensSessionObserver::Notification notification)
|
||||
{
|
||||
if (m_sessionObserver)
|
||||
{
|
||||
m_sessionObserver->handleSessionNotification(this, notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user