mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
working flow. Needs clean up and final ui tweaks
This commit is contained in:
parent
ae35ec0975
commit
7cce153b6d
3 changed files with 98 additions and 81 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -31,8 +32,7 @@
|
||||||
#include <RenderableTextEntityItem.h>
|
#include <RenderableTextEntityItem.h>
|
||||||
#include <RenderableWebEntityItem.h>
|
#include <RenderableWebEntityItem.h>
|
||||||
|
|
||||||
ScreenshareScriptingInterface::ScreenshareScriptingInterface() {
|
ScreenshareScriptingInterface::ScreenshareScriptingInterface(){};
|
||||||
};
|
|
||||||
|
|
||||||
ScreenshareScriptingInterface::~ScreenshareScriptingInterface() {
|
ScreenshareScriptingInterface::~ScreenshareScriptingInterface() {
|
||||||
stopScreenshare();
|
stopScreenshare();
|
||||||
|
@ -40,18 +40,20 @@ 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.0862f, 0.0311f);
|
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION(0.0f, -0.0862f, 0.0711f);
|
||||||
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";
|
||||||
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_DIMENSIONS(4.0419f, 2.2735f, 0.0100f);
|
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) {
|
QString token;
|
||||||
|
QString apiKey;
|
||||||
|
QString sessionID;
|
||||||
|
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.
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(this, "startScreenshare", Q_ARG(const QUuid&, screenshareZoneID),
|
||||||
this, "startScreenshare",
|
Q_ARG(const QUuid&, smartboardEntityID), Q_ARG(const bool&, isPresenter));
|
||||||
Q_ARG(const QUuid&, screenshareZoneID),
|
|
||||||
Q_ARG(const QUuid&, smartboardEntityID),
|
|
||||||
Q_ARG(const bool&, isPresenter)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
// 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();
|
QNetworkAccessManager* manager = new QNetworkAccessManager();
|
||||||
QObject::connect(manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
|
QObject::connect(manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply* reply) {
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
qDebug() << "\n\n MN HERE: REPLY" << reply->errorString();
|
qDebug() << "\n\n MN HERE: REPLY" << reply->errorString();
|
||||||
return;
|
return;
|
||||||
|
@ -85,27 +87,31 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
QString answer = reply->readAll();
|
QString answer = reply->readAll();
|
||||||
qDebug() << "\n\n MN HERE: REPLY" << answer;
|
qDebug() << "\n\n MN HERE: REPLY" << answer;
|
||||||
|
|
||||||
|
QByteArray answerByteArray = answer.toUtf8();
|
||||||
QString token = "";
|
QJsonDocument answerJSONObject = QJsonDocument::fromJson(answerByteArray);
|
||||||
QString apiKey = "";
|
|
||||||
QString sessionID = "";
|
token = answerJSONObject["token"].toString();
|
||||||
|
apiKey = answerJSONObject["apiKey"].toString();
|
||||||
|
sessionID = answerJSONObject["sessionId"].toString(); // hifi-test has Id camel-case. Change for metaverse.
|
||||||
|
qDebug() << "token:" << token << " apiKey:" << apiKey << " sessionID: " << sessionID;
|
||||||
|
|
||||||
if (isPresenter) {
|
if (isPresenter) {
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "--token=" + token;
|
arguments << "--token=" + token;
|
||||||
arguments << "--apiKey=" + apiKey;
|
arguments << "--apiKey=" + apiKey;
|
||||||
arguments << "--sessionID=" + sessionID;
|
arguments << "--sessionID=" + sessionID;
|
||||||
|
|
||||||
connect(_screenshareProcess.get(), &QProcess::errorOccurred,
|
connect(_screenshareProcess.get(), &QProcess::errorOccurred,
|
||||||
[=](QProcess::ProcessError error) { qDebug() << "ZRF QProcess::errorOccurred. `error`:" << error; });
|
[=](QProcess::ProcessError error) { qDebug() << "ZRF QProcess::errorOccurred. `error`:" << error; });
|
||||||
connect(_screenshareProcess.get(), &QProcess::started, [=]() { qDebug() << "ZRF QProcess::started"; });
|
connect(_screenshareProcess.get(), &QProcess::started, [=]() { qDebug() << "ZRF QProcess::started"; });
|
||||||
connect(_screenshareProcess.get(), &QProcess::stateChanged,
|
connect(_screenshareProcess.get(), &QProcess::stateChanged, [=](QProcess::ProcessState newState) {
|
||||||
[=](QProcess::ProcessState newState) { qDebug() << "ZRF QProcess::stateChanged. `newState`:" << newState; });
|
qDebug() << "ZRF QProcess::stateChanged. `newState`:" << newState;
|
||||||
|
});
|
||||||
connect(_screenshareProcess.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(_screenshareProcess.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||||
qDebug() << "ZRF QProcess::finished. `exitCode`:" << exitCode << "`exitStatus`:" << exitStatus;
|
qDebug() << "ZRF QProcess::finished. `exitCode`:" << exitCode << "`exitStatus`:" << exitStatus;
|
||||||
emit screenshareStopped();
|
emit screenshareStopped();
|
||||||
});
|
});
|
||||||
|
|
||||||
_screenshareProcess->start(SCREENSHARE_EXE_PATH, arguments);
|
_screenshareProcess->start(SCREENSHARE_EXE_PATH, arguments);
|
||||||
}
|
}
|
||||||
|
@ -135,50 +141,56 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
|
||||||
QString hostType = "local";
|
QString hostType = "local";
|
||||||
_screenshareViewerLocalWebEntityUUID = esi->addEntity(localScreenshareWebEntityProps, hostType);
|
_screenshareViewerLocalWebEntityUUID = esi->addEntity(localScreenshareWebEntityProps, hostType);
|
||||||
|
|
||||||
QObject::connect(esi.data(), &EntityScriptingInterface::webEventReceived, this, [&](const QUuid& entityID, const QVariant& message) {
|
QObject::connect(esi.data(), &EntityScriptingInterface::webEventReceived, this,
|
||||||
if (entityID == _screenshareViewerLocalWebEntityUUID) {
|
[&](const QUuid& entityID, const QVariant& message) {
|
||||||
qDebug() << "ZRF HERE! Inside `webEventReceived(). `entityID`:" << entityID << "`_screenshareViewerLocalWebEntityUUID`:" << _screenshareViewerLocalWebEntityUUID;
|
if (entityID == _screenshareViewerLocalWebEntityUUID) {
|
||||||
|
qDebug() << "ZRF HERE! Inside `webEventReceived(). `entityID`:" << entityID
|
||||||
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
<< "`_screenshareViewerLocalWebEntityUUID`:" << _screenshareViewerLocalWebEntityUUID;
|
||||||
if (!esi) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonDocument jsonMessage = QJsonDocument::fromVariant(message);
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
QJsonObject jsonObject = jsonMessage.object();
|
if (!esi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "ZRF HERE! Inside `webEventReceived(). `message`:" << message << "`jsonMessage`:" << jsonMessage;
|
qDebug() << "MN HERE! message:" << message;
|
||||||
|
QByteArray jsonByteArray = QVariant(message).toString().toUtf8();
|
||||||
|
QJsonDocument jsonObject = QJsonDocument::fromJson(jsonByteArray);
|
||||||
|
|
||||||
if (jsonObject["app"] != "screenshare") {
|
qDebug() << "ZRF HERE! Inside `webEventReceived(). `message`:" << message
|
||||||
return;
|
<< "`jsonObject`:" << jsonObject;
|
||||||
}
|
qDebug() << jsonObject["app"];
|
||||||
|
if (jsonObject["app"] != "screenshare") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "ZRF HERE! Inside `webEventReceived(). we're still here!";
|
qDebug() << "ZRF HERE! Inside `webEventReceived(). we're still here!";
|
||||||
|
|
||||||
if (jsonObject["method"] == "eventBridgeReady") {
|
if (jsonObject["method"] == "eventBridgeReady") {
|
||||||
QJsonObject responseObject;
|
QJsonObject responseObject;
|
||||||
responseObject.insert("app", "screenshare");
|
responseObject.insert("app", "screenshare");
|
||||||
responseObject.insert("method", "receiveConnectionInfo");
|
responseObject.insert("method", "receiveConnectionInfo");
|
||||||
QJsonObject responseObjectData;
|
QJsonObject responseObjectData;
|
||||||
responseObjectData.insert("token", token);
|
responseObjectData.insert("token", token);
|
||||||
responseObjectData.insert("projectAPIKey", apiKey);
|
responseObjectData.insert("projectAPIKey", apiKey);
|
||||||
responseObjectData.insert("sessionID", sessionID);
|
responseObjectData.insert("sessionID", sessionID);
|
||||||
responseObject.insert("data", responseObjectData);
|
responseObject.insert("data", responseObjectData);
|
||||||
|
|
||||||
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
|
// Attempt 1, we receive the eventBridge message, but this won't send a message
|
||||||
// to that js
|
// to that js
|
||||||
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
esi->emitScriptEvent(_screenshareViewerLocalWebEntityUUID, responseObject.toVariantMap());
|
esi->emitScriptEvent(_screenshareViewerLocalWebEntityUUID, responseObject.toVariantMap());
|
||||||
|
|
||||||
// atempt 2, same outcome
|
// atempt 2, same outcome
|
||||||
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
//auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
auto webEntityRenderable = entityTreeRenderer->renderableForEntityId(_screenshareViewerLocalWebEntityUUID);
|
//auto webEntityRenderable =
|
||||||
webEntityRenderable->emitScriptEvent(responseObject.toVariantMap());
|
// entityTreeRenderer->renderableForEntityId(_screenshareViewerLocalWebEntityUUID);
|
||||||
}
|
//webEntityRenderable->emitScriptEvent(responseObject.toVariantMap());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
|
|
|
@ -243,20 +243,21 @@ function togglePage(){
|
||||||
|
|
||||||
|
|
||||||
// main TODO:
|
// main TODO:
|
||||||
// const {ipcRenderer} = ipcRenderer;
|
const ipcRenderer = electron.ipcRenderer;
|
||||||
// let apiKey;
|
let apiKey;
|
||||||
// let sessionId;
|
let sessionId;
|
||||||
// let token;
|
let token;
|
||||||
// let session;
|
let session;
|
||||||
// ipcRenderer.on('connectionInfo', function(event, message){
|
|
||||||
// console.log("event", event);
|
ipcRenderer.on('connectionInfo', function(event, message){
|
||||||
// console.log("MESSAGE FROM MAIN", message);
|
console.log("event:" + event);
|
||||||
// const connectionInfo = JSON.parse(message);
|
console.log("MESSAGE FROM MAIN:" + message);
|
||||||
|
// const connectionInfo = JSON.parse(message);
|
||||||
// apiKey = connectionInfo.apiKey;
|
// apiKey = connectionInfo.apiKey;
|
||||||
// sessionId = connectionInfo.sessionId;
|
// sessionId = connectionInfo.sessionId;
|
||||||
// token = connectionInfo.token;
|
// token = connectionInfo.token;
|
||||||
// initializeTokboxSession();
|
// initializeTokboxSession();
|
||||||
// })
|
})
|
||||||
|
|
||||||
function startup(){
|
function startup(){
|
||||||
console.log("\n\n IN STARTUP \n\n")
|
console.log("\n\n IN STARTUP \n\n")
|
||||||
|
|
|
@ -6,7 +6,8 @@ const {app, BrowserWindow, ipcMain} = require('electron');
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv;
|
||||||
// ./screenshare.exe --userName=miladN ...
|
// ./screenshare.exe --userName=miladN ...
|
||||||
|
console.log("argV:", argv)
|
||||||
|
console.log("argV Username", argv.userName);
|
||||||
const connectionInfo = {
|
const connectionInfo = {
|
||||||
userName: argv.userName || "testName",
|
userName: argv.userName || "testName",
|
||||||
displayName: argv.displayName || "displayName",
|
displayName: argv.displayName || "displayName",
|
||||||
|
@ -23,6 +24,7 @@ if (!gotTheLock) {
|
||||||
|
|
||||||
var window;
|
var window;
|
||||||
function createWindow(){
|
function createWindow(){
|
||||||
|
console.log("Creating window")
|
||||||
const zoomFactor = 1.0;
|
const zoomFactor = 1.0;
|
||||||
window = new BrowserWindow({
|
window = new BrowserWindow({
|
||||||
backgroundColor: "#000000",
|
backgroundColor: "#000000",
|
||||||
|
@ -33,24 +35,26 @@ function createWindow(){
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
zoomFactor: zoomFactor,
|
zoomFactor: zoomFactor,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
alwaysOnTop: false, // TRY
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.loadURL('file://' + __dirname + '/index.html');
|
window.loadURL('file://' + __dirname + '/index.html');
|
||||||
window.setMenu(null);
|
window.setMenu(null);
|
||||||
|
|
||||||
|
window.webContents.on("did-finish-load", function(){
|
||||||
|
console.log("connectionInfo:", connectionInfo)
|
||||||
|
console.log("in did finish loading");
|
||||||
|
window.webContents.send('connectionInfo', JSON.stringify(connectionInfo));
|
||||||
|
});
|
||||||
|
|
||||||
window.once('ready-to-show', () => {
|
|
||||||
window.show();
|
|
||||||
window.webContents.openDevTools()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
|
console.log("setting up on ready");
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
|
console.log("app ready");
|
||||||
createWindow();
|
createWindow();
|
||||||
console.log("sending info");
|
});
|
||||||
window.webContents.send('connectionInfo', JSON.stringify(connectionInfo))
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in a new issue