mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:17:58 +02:00
updated api to try and communicate over EB, but still not working
This commit is contained in:
parent
b206c102e8
commit
c7b8d97639
2 changed files with 137 additions and 91 deletions
|
@ -2,7 +2,7 @@
|
||||||
// ScreenshareScriptingInterface.cpp
|
// ScreenshareScriptingInterface.cpp
|
||||||
// interface/src/scripting/
|
// interface/src/scripting/
|
||||||
//
|
//
|
||||||
// Created by Milad Nazeri on 2019-10-23.
|
// Created by Milad Nazeri and Zach Fox on 2019-10-23.
|
||||||
// Copyright 2019 High Fidelity, Inc.
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
@ -14,12 +14,23 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
|
#include <EntityTreeRenderer.h>
|
||||||
|
#include <EntityTree.h>
|
||||||
|
|
||||||
#include "EntityScriptingInterface.h"
|
#include "EntityScriptingInterface.h"
|
||||||
#include "ScreenshareScriptingInterface.h"
|
#include "ScreenshareScriptingInterface.h"
|
||||||
|
|
||||||
|
#include <RenderableEntityItem.h>
|
||||||
|
#include <RenderableTextEntityItem.h>
|
||||||
|
#include <RenderableWebEntityItem.h>
|
||||||
|
|
||||||
ScreenshareScriptingInterface::ScreenshareScriptingInterface() {
|
ScreenshareScriptingInterface::ScreenshareScriptingInterface() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,8 +40,9 @@ ScreenshareScriptingInterface::~ScreenshareScriptingInterface() {
|
||||||
|
|
||||||
static const EntityTypes::EntityType LOCAL_SCREENSHARE_WEB_ENTITY_TYPE = EntityTypes::Web;
|
static const EntityTypes::EntityType LOCAL_SCREENSHARE_WEB_ENTITY_TYPE = EntityTypes::Web;
|
||||||
static const uint8_t LOCAL_SCREENSHARE_WEB_ENTITY_FPS = 30;
|
static const uint8_t LOCAL_SCREENSHARE_WEB_ENTITY_FPS = 30;
|
||||||
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION(0.0f, 0.0f, 0.1f);
|
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION(0.0f, -0.0862f, 0.0311f);
|
||||||
static const QString LOCAL_SCREENSHARE_WEB_ENTITY_URL = "https://hifi-content.s3.amazonaws.com/Experiences/Releases/usefulUtilities/smartBoard/screenshareViewer/screenshareClient.html?1";
|
static const QString LOCAL_SCREENSHARE_WEB_ENTITY_URL = "https://hifi-content.s3.amazonaws.com/Experiences/Releases/usefulUtilities/smartBoard/screenshareViewer/screenshareClient.html?1";
|
||||||
|
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_DIMENSIONS(4.0419f, 2.2735f, 0.0100f);
|
||||||
void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZoneID, const QUuid& smartboardEntityID, const bool& isPresenter) {
|
void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZoneID, const QUuid& smartboardEntityID, const bool& isPresenter) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// We must start a new QProcess from the main thread.
|
// We must start a new QProcess from the main thread.
|
||||||
|
@ -59,12 +71,21 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid currentDomainID = DependencyManager::get<AddressManager>()->getDomainID();
|
QUuid currentDomainID = DependencyManager::get<AddressManager>()->getDomainID();
|
||||||
|
|
||||||
// Make HTTP GET request to:
|
|
||||||
// `https://metaverse.highfidelity.com/api/v1/domain/:domain_id/screenshare`,
|
// `https://metaverse.highfidelity.com/api/v1/domain/:domain_id/screenshare`,
|
||||||
// passing the Domain ID that the user is connected to, as well as the `roomName`.
|
// passing the Domain ID that the user is connected to, as well as the `roomName`.
|
||||||
// The server will respond with the relevant OpenTok Token, Session ID, and API Key.
|
// The server will respond with the relevant OpenTok Token, Session ID, and API Key.
|
||||||
// Upon error-free response, do the logic below, passing in that info as necessary.
|
// Upon error-free response, do the logic below, passing in that info as necessary.
|
||||||
|
QNetworkAccessManager* manager = new QNetworkAccessManager();
|
||||||
|
QObject::connect(manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
|
||||||
|
if (reply->error()) {
|
||||||
|
qDebug() << "\n\n MN HERE: REPLY" << reply->errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString answer = reply->readAll();
|
||||||
|
qDebug() << "\n\n MN HERE: REPLY" << answer;
|
||||||
|
|
||||||
|
|
||||||
QString token = "";
|
QString token = "";
|
||||||
QString apiKey = "";
|
QString apiKey = "";
|
||||||
QString sessionID = "";
|
QString sessionID = "";
|
||||||
|
@ -104,14 +125,12 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
localScreenshareWebEntityProps.setLocalPosition(LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION);
|
localScreenshareWebEntityProps.setLocalPosition(LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION);
|
||||||
localScreenshareWebEntityProps.setSourceUrl(LOCAL_SCREENSHARE_WEB_ENTITY_URL);
|
localScreenshareWebEntityProps.setSourceUrl(LOCAL_SCREENSHARE_WEB_ENTITY_URL);
|
||||||
localScreenshareWebEntityProps.setParentID(smartboardEntityID);
|
localScreenshareWebEntityProps.setParentID(smartboardEntityID);
|
||||||
|
localScreenshareWebEntityProps.setDimensions(LOCAL_SCREENSHARE_WEB_ENTITY_DIMENSIONS);
|
||||||
|
|
||||||
EntityPropertyFlags desiredSmartboardProperties;
|
// EntityPropertyFlags desiredSmartboardProperties;
|
||||||
desiredSmartboardProperties += PROP_POSITION;
|
// desiredSmartboardProperties += PROP_POSITION;
|
||||||
desiredSmartboardProperties += PROP_DIMENSIONS;
|
// desiredSmartboardProperties += PROP_DIMENSIONS;
|
||||||
EntityItemProperties smartboardProps = esi->getEntityProperties(smartboardEntityID, desiredSmartboardProperties);
|
// EntityItemProperties smartboardProps = esi->getEntityProperties(smartboardEntityID, desiredSmartboardProperties);
|
||||||
|
|
||||||
localScreenshareWebEntityProps.setPosition(smartboardProps.getPosition());
|
|
||||||
localScreenshareWebEntityProps.setDimensions(smartboardProps.getDimensions());
|
|
||||||
|
|
||||||
QString hostType = "local";
|
QString hostType = "local";
|
||||||
_screenshareViewerLocalWebEntityUUID = esi->addEntity(localScreenshareWebEntityProps, hostType);
|
_screenshareViewerLocalWebEntityUUID = esi->addEntity(localScreenshareWebEntityProps, hostType);
|
||||||
|
@ -148,10 +167,24 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
|
|
||||||
qDebug() << "ZRF HERE! Inside `webEventReceived(). `responseObject.toVariantMap()`:" << responseObject.toVariantMap();
|
qDebug() << "ZRF HERE! Inside `webEventReceived(). `responseObject.toVariantMap()`:" << responseObject.toVariantMap();
|
||||||
|
|
||||||
|
// Attempt 1, we receive the eventBridge message, but this won't send a message
|
||||||
|
// to that js
|
||||||
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
esi->emitScriptEvent(_screenshareViewerLocalWebEntityUUID, responseObject.toVariantMap());
|
esi->emitScriptEvent(_screenshareViewerLocalWebEntityUUID, responseObject.toVariantMap());
|
||||||
|
|
||||||
|
// atempt 2, same outcome
|
||||||
|
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
|
auto webEntityRenderable = entityTreeRenderer->renderableForEntityId(_screenshareViewerLocalWebEntityUUID);
|
||||||
|
webEntityRenderable->emitScriptEvent(responseObject.toVariantMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
QNetworkRequest request;
|
||||||
|
QString tokboxURL = QProcessEnvironment::systemEnvironment().value("hifiScreenshareUrl");
|
||||||
|
request.setUrl(QUrl(tokboxURL));
|
||||||
|
manager->get(request);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ScreenshareScriptingInterface::stopScreenshare() {
|
void ScreenshareScriptingInterface::stopScreenshare() {
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
|
//
|
||||||
|
// ScreenshareScriptingInterface.h
|
||||||
|
// interface/src/scripting/
|
||||||
|
//
|
||||||
|
// Created by Milad Nazeri and Zach Fox on 2019-10-23.
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef hifi_ScreenshareScriptingInterface_h
|
#ifndef hifi_ScreenshareScriptingInterface_h
|
||||||
#define hifi_ScreenshareScriptingInterface_h
|
#define hifi_ScreenshareScriptingInterface_h
|
||||||
|
|
||||||
#include <QObject>
|
// #include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
// #include <QNetworkAccessManager>
|
||||||
|
// #include <QNetworkReply>
|
||||||
|
// #include <QNetworkRequest>
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue