clean up code

This commit is contained in:
milad 2019-11-12 11:37:07 -08:00
parent 7cce153b6d
commit 0f605ffc43
3 changed files with 25 additions and 54 deletions

View file

@ -40,12 +40,14 @@ ScreenshareScriptingInterface::~ScreenshareScriptingInterface() {
static const EntityTypes::EntityType LOCAL_SCREENSHARE_WEB_ENTITY_TYPE = EntityTypes::Web;
static const uint8_t LOCAL_SCREENSHARE_WEB_ENTITY_FPS = 30;
// This is going to be a good amount of work to make this work dynamically for any screensize.
// V1 will have only hardcoded values.
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION(0.0f, -0.0862f, 0.0711f);
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_DIMENSIONS(4.0419f, 2.2735f, 0.0100f);
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);
QString token;
QString apiKey;
QString projectAPIKey;
QString sessionID;
void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZoneID,
const QUuid& smartboardEntityID,
@ -91,15 +93,16 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
QJsonDocument answerJSONObject = QJsonDocument::fromJson(answerByteArray);
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;
projectAPIKey = answerJSONObject["projectAPIKey"].toString();
sessionID = answerJSONObject["sessionID"].toString(); // hifi-test has Id camel-case. Change for metaverse.
qDebug() << "token:" << token << " projectAPIKey:" << projectAPIKey << " sessionID: " << sessionID;
if (isPresenter) {
QStringList arguments;
arguments << "--token=" + token;
arguments << "--apiKey=" + apiKey;
arguments << "--sessionID=" + sessionID;
arguments << " ";
arguments << "--token=" + token << " ";
arguments << "--projectAPIKey=" + projectAPIKey << " ";
arguments << "--sessionID=" + sessionID << " ";
connect(_screenshareProcess.get(), &QProcess::errorOccurred,
[=](QProcess::ProcessError error) { qDebug() << "ZRF QProcess::errorOccurred. `error`:" << error; });
@ -171,23 +174,15 @@ void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZon
responseObject.insert("method", "receiveConnectionInfo");
QJsonObject responseObjectData;
responseObjectData.insert("token", token);
responseObjectData.insert("projectAPIKey", apiKey);
responseObjectData.insert("projectAPIKey", projectAPIKey);
responseObjectData.insert("sessionID", sessionID);
responseObject.insert("data", responseObjectData);
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());
// atempt 2, same outcome
//auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
//auto webEntityRenderable =
// entityTreeRenderer->renderableForEntityId(_screenshareViewerLocalWebEntityUUID);
//webEntityRenderable->emitScriptEvent(responseObject.toVariantMap());
}
}
});

View file

@ -192,8 +192,9 @@ function togglePage(){
function initializeTokboxSession() {
console.log("\n\n\n\n #$######\n TRYING TO START SESSION")
session = OT.initSession(apiKey, sessionId);
console.log("projectAPIKey: " + projectAPIKey)
console.log("sessionId: " + sessionID)
session = OT.initSession(projectAPIKey, sessionID);
session.on('sessionDisconnected', (event) => {
console.log('You were disconnected from the session.', event.reason);
});
@ -244,43 +245,24 @@ function togglePage(){
// main TODO:
const ipcRenderer = electron.ipcRenderer;
let apiKey;
let sessionId;
let projectAPIKey;
let sessionID;
let token;
let session;
ipcRenderer.on('connectionInfo', function(event, message){
console.log("event:" + event);
console.log("MESSAGE FROM MAIN:" + message);
// const connectionInfo = JSON.parse(message);
// apiKey = connectionInfo.apiKey;
// sessionId = connectionInfo.sessionId;
// token = connectionInfo.token;
// initializeTokboxSession();
const connectionInfo = JSON.parse(message);
projectAPIKey = connectionInfo.projectAPIKey;
console.log()
sessionID = connectionInfo.sessionID;
token = connectionInfo.token;
initializeTokboxSession();
})
function startup(){
console.log("\n\n IN STARTUP \n\n")
// Make an Ajax request to get the OpenTok API key, session ID, and token from the server
// TODO:
fetch(process.env.hifiScreenshareURL)
.then(function(res) {
return res.json();
})
.then(function fetchJson(json) {
apiKey = json.apiKey;
sessionId = json.sessionId;
token = json.token;
initializeTokboxSession();
})
.catch(function catchErr(error) {
handleError(error);
alert('Failed to get opentok sessionId and token. Make sure you have updated the config.js file.');
});
}
document.addEventListener("DOMContentLoaded", () => {
startup();
showSources();
})

View file

@ -1,18 +1,12 @@
'use strict';
var userName, displayName, token, apiKey, sessionID;
const {app, BrowserWindow, ipcMain} = require('electron');
const gotTheLock = app.requestSingleInstanceLock()
const argv = require('yargs').argv;
// ./screenshare.exe --userName=miladN ...
console.log("argV:", argv)
console.log("argV Username", argv.userName);
const connectionInfo = {
userName: argv.userName || "testName",
displayName: argv.displayName || "displayName",
token: argv.token || "token",
apiKey: argv.apiKey || "apiKey",
projectAPIKey: argv.projectAPIKey || "projectAPIKey",
sessionID: argv.sessionID || "sessionID"
}