mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 00:36:52 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into xboxLasers
This commit is contained in:
commit
62f63f32a7
18 changed files with 225 additions and 154 deletions
14
interface/resources/qml/ConnectionFailureDialog.qml
Normal file
14
interface/resources/qml/ConnectionFailureDialog.qml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import QtQuick.Dialogs 1.2 as OriginalDialogs
|
||||||
|
|
||||||
|
import "dialogs"
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: root
|
||||||
|
objectName: "ConnectionFailureDialog"
|
||||||
|
|
||||||
|
title: "No Connection"
|
||||||
|
text: "Unable to connect to this domain. Click the 'GO TO' button on the toolbar to visit another domain."
|
||||||
|
buttons: OriginalDialogs.StandardButton.Ok
|
||||||
|
icon: OriginalDialogs.StandardIcon.Warning
|
||||||
|
defaultButton: OriginalDialogs.StandardButton.NoButton;
|
||||||
|
}
|
|
@ -882,8 +882,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
UserActivityLogger::getInstance().logAction("launch", properties);
|
UserActivityLogger::getInstance().logAction("launch", properties);
|
||||||
|
|
||||||
_connectionMonitor.init();
|
|
||||||
|
|
||||||
// Tell our entity edit sender about our known jurisdictions
|
// Tell our entity edit sender about our known jurisdictions
|
||||||
_entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
|
_entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
|
||||||
_entityEditSender.setMyAvatar(myAvatar.get());
|
_entityEditSender.setMyAvatar(myAvatar.get());
|
||||||
|
@ -1376,6 +1374,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_connectionMonitor.init();
|
||||||
|
|
||||||
// After all of the constructor is completed, then set firstRun to false.
|
// After all of the constructor is completed, then set firstRun to false.
|
||||||
firstRun.set(false);
|
firstRun.set(false);
|
||||||
}
|
}
|
||||||
|
@ -2165,13 +2165,10 @@ void Application::resizeGL() {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
auto uiSize = displayPlugin->getRecommendedUiSize();
|
auto uiSize = displayPlugin->getRecommendedUiSize();
|
||||||
// Bit of a hack since there's no device pixel ratio change event I can find.
|
// Bit of a hack since there's no device pixel ratio change event I can find.
|
||||||
static qreal lastDevicePixelRatio = 0;
|
if (offscreenUi->size() != fromGlm(uiSize)) {
|
||||||
qreal devicePixelRatio = _window->devicePixelRatio();
|
|
||||||
if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) {
|
|
||||||
qCDebug(interfaceapp) << "Device pixel ratio changed, triggering resize to " << uiSize;
|
qCDebug(interfaceapp) << "Device pixel ratio changed, triggering resize to " << uiSize;
|
||||||
offscreenUi->resize(fromGlm(uiSize), true);
|
offscreenUi->resize(fromGlm(uiSize), true);
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
lastDevicePixelRatio = devicePixelRatio;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,34 +13,42 @@
|
||||||
|
|
||||||
#include "ui/DialogsManager.h"
|
#include "ui/DialogsManager.h"
|
||||||
|
|
||||||
#include <NodeList.h>
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <DomainHandler.h>
|
#include <DomainHandler.h>
|
||||||
#include <AddressManager.h>
|
#include <NodeList.h>
|
||||||
|
|
||||||
|
// Because the connection monitor is created at startup, the time we wait on initial load
|
||||||
|
// should be longer to allow the application to initialize.
|
||||||
|
static const int ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 10000;
|
||||||
static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
|
static const int DISPLAY_AFTER_DISCONNECTED_FOR_X_MS = 5000;
|
||||||
|
|
||||||
void ConnectionMonitor::init() {
|
void ConnectionMonitor::init() {
|
||||||
// Connect to domain disconnected message
|
// Connect to domain disconnected message
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::disconnectedFromDomain);
|
connect(&domainHandler, &DomainHandler::resetting, this, &ConnectionMonitor::startTimer);
|
||||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::connectedToDomain);
|
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &ConnectionMonitor::startTimer);
|
||||||
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::stopTimer);
|
||||||
|
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ConnectionMonitor::stopTimer);
|
||||||
|
|
||||||
_timer.setSingleShot(true);
|
_timer.setSingleShot(true);
|
||||||
_timer.setInterval(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
|
|
||||||
if (!domainHandler.isConnected()) {
|
if (!domainHandler.isConnected()) {
|
||||||
_timer.start();
|
_timer.start(ON_INITIAL_LOAD_DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
connect(&_timer, &QTimer::timeout, this, []() {
|
||||||
connect(&_timer, &QTimer::timeout, dialogsManager.data(), &DialogsManager::indicateDomainConnectionFailure);
|
qDebug() << "ConnectionMonitor: Showing connection failure window";
|
||||||
|
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionMonitor::disconnectedFromDomain() {
|
void ConnectionMonitor::startTimer() {
|
||||||
_timer.start();
|
qDebug() << "ConnectionMonitor: Starting timer";
|
||||||
|
_timer.start(DISPLAY_AFTER_DISCONNECTED_FOR_X_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionMonitor::connectedToDomain(const QString& name) {
|
void ConnectionMonitor::stopTimer() {
|
||||||
|
qDebug() << "ConnectionMonitor: Stopping timer";
|
||||||
_timer.stop();
|
_timer.stop();
|
||||||
|
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void disconnectedFromDomain();
|
void startTimer();
|
||||||
void connectedToDomain(const QString& name);
|
void stopTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer _timer;
|
QTimer _timer;
|
||||||
|
|
3
interface/src/ui/ConnectionFailureDialog.cpp
Normal file
3
interface/src/ui/ConnectionFailureDialog.cpp
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "ConnectionFailureDialog.h"
|
||||||
|
|
||||||
|
HIFI_QML_DEF(ConnectionFailureDialog)
|
8
interface/src/ui/ConnectionFailureDialog.h
Normal file
8
interface/src/ui/ConnectionFailureDialog.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <OffscreenQmlDialog.h>
|
||||||
|
|
||||||
|
class ConnectionFailureDialog : public OffscreenQmlDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
HIFI_QML_DECL
|
||||||
|
};
|
|
@ -21,6 +21,7 @@
|
||||||
#include "AddressBarDialog.h"
|
#include "AddressBarDialog.h"
|
||||||
#include "BandwidthDialog.h"
|
#include "BandwidthDialog.h"
|
||||||
#include "CachesSizeDialog.h"
|
#include "CachesSizeDialog.h"
|
||||||
|
#include "ConnectionFailureDialog.h"
|
||||||
#include "DiskCacheEditor.h"
|
#include "DiskCacheEditor.h"
|
||||||
#include "DomainConnectionDialog.h"
|
#include "DomainConnectionDialog.h"
|
||||||
#include "HMDToolsDialog.h"
|
#include "HMDToolsDialog.h"
|
||||||
|
@ -59,8 +60,12 @@ void DialogsManager::showFeed() {
|
||||||
emit setUseFeed(true);
|
emit setUseFeed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::indicateDomainConnectionFailure() {
|
void DialogsManager::setDomainConnectionFailureVisibility(bool visible) {
|
||||||
OffscreenUi::information("No Connection", "Unable to connect to this domain. Click the 'GO TO' button on the toolbar to visit another domain.");
|
if (visible) {
|
||||||
|
ConnectionFailureDialog::show();
|
||||||
|
} else {
|
||||||
|
ConnectionFailureDialog::hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::toggleDiskCacheEditor() {
|
void DialogsManager::toggleDiskCacheEditor() {
|
||||||
|
|
|
@ -44,7 +44,7 @@ public slots:
|
||||||
void toggleAddressBar();
|
void toggleAddressBar();
|
||||||
void showAddressBar();
|
void showAddressBar();
|
||||||
void showFeed();
|
void showFeed();
|
||||||
void indicateDomainConnectionFailure();
|
void setDomainConnectionFailureVisibility(bool visible);
|
||||||
void toggleDiskCacheEditor();
|
void toggleDiskCacheEditor();
|
||||||
void toggleLoginDialog();
|
void toggleLoginDialog();
|
||||||
void showLoginDialog();
|
void showLoginDialog();
|
||||||
|
|
|
@ -430,26 +430,23 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
|
||||||
rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath()));
|
rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uvec2 clampSize(const uvec2& size, uint32_t maxDimension) {
|
||||||
|
return glm::clamp(size, glm::uvec2(1), glm::uvec2(maxDimension));
|
||||||
|
}
|
||||||
|
|
||||||
|
static QSize clampSize(const QSize& qsize, uint32_t maxDimension) {
|
||||||
|
return fromGlm(clampSize(toGlm(qsize), maxDimension));
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
||||||
|
|
||||||
if (!_quickWindow) {
|
if (!_quickWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float MAX_OFFSCREEN_DIMENSION = 4096;
|
const uint32_t MAX_OFFSCREEN_DIMENSION = 4096;
|
||||||
QSize newSize = newSize_;
|
const QSize newSize = clampSize(newSize_, MAX_OFFSCREEN_DIMENSION);
|
||||||
|
if (!forceResize && newSize == _quickWindow->geometry().size()) {
|
||||||
if (newSize.width() > MAX_OFFSCREEN_DIMENSION || newSize.height() > MAX_OFFSCREEN_DIMENSION) {
|
|
||||||
float scale = std::min(
|
|
||||||
((float)newSize.width() / MAX_OFFSCREEN_DIMENSION),
|
|
||||||
((float)newSize.height() / MAX_OFFSCREEN_DIMENSION));
|
|
||||||
newSize = QSize(
|
|
||||||
std::max(static_cast<int>(scale * newSize.width()), 10),
|
|
||||||
std::max(static_cast<int>(scale * newSize.height()), 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize currentSize = _quickWindow->geometry().size();
|
|
||||||
if (newSize == currentSize && !forceResize) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,17 +462,12 @@ void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) {
|
||||||
|
|
||||||
// Qt bug in 5.4 forces this check of pixel ratio,
|
// Qt bug in 5.4 forces this check of pixel ratio,
|
||||||
// even though we're rendering offscreen.
|
// even though we're rendering offscreen.
|
||||||
qreal pixelRatio = 1.0;
|
uvec2 newOffscreenSize = toGlm(newSize);
|
||||||
if (_renderControl && _renderControl->_renderWindow) {
|
|
||||||
pixelRatio = _renderControl->_renderWindow->devicePixelRatio();
|
|
||||||
}
|
|
||||||
|
|
||||||
uvec2 newOffscreenSize = toGlm(newSize * pixelRatio);
|
|
||||||
if (newOffscreenSize == _size) {
|
if (newOffscreenSize == _size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(glLogging) << "Offscreen UI resizing to " << newSize.width() << "x" << newSize.height() << " with pixel ratio " << pixelRatio;
|
qCDebug(glLogging) << "Offscreen UI resizing to " << newSize.width() << "x" << newSize.height();
|
||||||
|
|
||||||
_canvas->makeCurrent();
|
_canvas->makeCurrent();
|
||||||
|
|
||||||
|
|
|
@ -18,22 +18,6 @@ using namespace gpu::gl;
|
||||||
|
|
||||||
std::shared_ptr<GLTextureTransferHelper> GLTexture::_textureTransferHelper;
|
std::shared_ptr<GLTextureTransferHelper> GLTexture::_textureTransferHelper;
|
||||||
|
|
||||||
// FIXME placeholder for texture memory over-use
|
|
||||||
#define DEFAULT_MAX_MEMORY_MB 256
|
|
||||||
#define OVER_MEMORY_PRESSURE 2.0f
|
|
||||||
|
|
||||||
// FIXME other apps show things like Oculus home consuming large amounts of GPU memory
|
|
||||||
// which causes us to blur textures needlessly (since other app GPU memory usage will likely
|
|
||||||
// be swapped out and not cause any actual impact
|
|
||||||
//#define CHECK_MIN_FREE_GPU_MEMORY
|
|
||||||
#ifdef CHECK_MIN_FREE_GPU_MEMORY
|
|
||||||
#define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Allow 65% of all available GPU memory to be consumed by textures
|
|
||||||
// FIXME overly conservative?
|
|
||||||
#define MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE 0.65f
|
|
||||||
|
|
||||||
const GLenum GLTexture::CUBE_FACE_LAYOUT[6] = {
|
const GLenum GLTexture::CUBE_FACE_LAYOUT[6] = {
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||||||
|
@ -105,37 +89,25 @@ const std::vector<GLenum>& GLTexture::getFaceTargets(GLenum target) {
|
||||||
return faceTargets;
|
return faceTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default texture memory = GPU total memory - 2GB
|
||||||
|
#define GPU_MEMORY_RESERVE_BYTES MB_TO_BYTES(2048)
|
||||||
|
// Minimum texture memory = 1GB
|
||||||
|
#define TEXTURE_MEMORY_MIN_BYTES MB_TO_BYTES(1024)
|
||||||
|
|
||||||
|
|
||||||
float GLTexture::getMemoryPressure() {
|
float GLTexture::getMemoryPressure() {
|
||||||
// Check for an explicit memory limit
|
// Check for an explicit memory limit
|
||||||
auto availableTextureMemory = Texture::getAllowedGPUMemoryUsage();
|
auto availableTextureMemory = Texture::getAllowedGPUMemoryUsage();
|
||||||
|
|
||||||
|
|
||||||
// If no memory limit has been set, use a percentage of the total dedicated memory
|
// If no memory limit has been set, use a percentage of the total dedicated memory
|
||||||
if (!availableTextureMemory) {
|
if (!availableTextureMemory) {
|
||||||
auto totalGpuMemory = getDedicatedMemory();
|
auto totalMemory = getDedicatedMemory();
|
||||||
|
if ((GPU_MEMORY_RESERVE_BYTES + TEXTURE_MEMORY_MIN_BYTES) > totalMemory) {
|
||||||
if (!totalGpuMemory) {
|
availableTextureMemory = TEXTURE_MEMORY_MIN_BYTES;
|
||||||
// If we can't query the dedicated memory just use a fallback fixed value of 256 MB
|
|
||||||
totalGpuMemory = MB_TO_BYTES(DEFAULT_MAX_MEMORY_MB);
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef CHECK_MIN_FREE_GPU_MEMORY
|
availableTextureMemory = totalMemory - GPU_MEMORY_RESERVE_BYTES;
|
||||||
// Check the global free GPU memory
|
|
||||||
auto freeGpuMemory = getFreeDedicatedMemory();
|
|
||||||
if (freeGpuMemory) {
|
|
||||||
static gpu::Size lastFreeGpuMemory = 0;
|
|
||||||
auto freePercentage = (float)freeGpuMemory / (float)totalGpuMemory;
|
|
||||||
if (freeGpuMemory != lastFreeGpuMemory) {
|
|
||||||
lastFreeGpuMemory = freeGpuMemory;
|
|
||||||
if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) {
|
|
||||||
qCDebug(gpugllogging) << "Exceeded min free GPU memory " << freePercentage;
|
|
||||||
return OVER_MEMORY_PRESSURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
availableTextureMemory = static_cast<gpu::Size>(totalGpuMemory * MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the consumed texture memory divided by the available texture memory.
|
// Return the consumed texture memory divided by the available texture memory.
|
||||||
|
|
|
@ -22,6 +22,7 @@ private: \
|
||||||
public: \
|
public: \
|
||||||
static void registerType(); \
|
static void registerType(); \
|
||||||
static void show(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
static void show(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||||
|
static void hide(); \
|
||||||
static void toggle(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
static void toggle(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||||
static void load(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
static void load(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
|
||||||
private:
|
private:
|
||||||
|
@ -33,6 +34,7 @@ protected: \
|
||||||
public: \
|
public: \
|
||||||
static void registerType(); \
|
static void registerType(); \
|
||||||
static void show(); \
|
static void show(); \
|
||||||
|
static void hide(); \
|
||||||
static void toggle(); \
|
static void toggle(); \
|
||||||
static void load(); \
|
static void load(); \
|
||||||
private:
|
private:
|
||||||
|
@ -50,6 +52,11 @@ private:
|
||||||
offscreenUi->show(QML, NAME, f); \
|
offscreenUi->show(QML, NAME, f); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
void x::hide() { \
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||||
|
offscreenUi->hide(NAME); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
|
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||||
offscreenUi->toggle(QML, NAME, f); \
|
offscreenUi->toggle(QML, NAME, f); \
|
||||||
|
@ -70,6 +77,11 @@ private:
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||||
offscreenUi->show(QML, NAME, f); \
|
offscreenUi->show(QML, NAME, f); \
|
||||||
} \
|
} \
|
||||||
|
void x::hide() { \
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||||
|
offscreenUi->hide(NAME); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
void x::toggle() { \
|
void x::toggle() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
||||||
offscreenUi->toggle(QML, NAME, f); \
|
offscreenUi->toggle(QML, NAME, f); \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hf-console",
|
"name": "HighFidelitySandbox",
|
||||||
"description": "High Fidelity Console",
|
"description": "High Fidelity Sandbox",
|
||||||
"author": "High Fidelity",
|
"author": "High Fidelity",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -33,6 +33,7 @@
|
||||||
"request": "^2.67.0",
|
"request": "^2.67.0",
|
||||||
"request-progress": "1.0.2",
|
"request-progress": "1.0.2",
|
||||||
"tar-fs": "^1.12.0",
|
"tar-fs": "^1.12.0",
|
||||||
"yargs": "^3.30.0"
|
"yargs": "^3.30.0",
|
||||||
|
"electron-log": "1.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ function getBuildInfo() {
|
||||||
var buildInfo = DEFAULT_BUILD_INFO;
|
var buildInfo = DEFAULT_BUILD_INFO;
|
||||||
|
|
||||||
if (buildInfoPath) {
|
if (buildInfoPath) {
|
||||||
console.log('Build info path:', buildInfoPath);
|
|
||||||
try {
|
try {
|
||||||
buildInfo = JSON.parse(fs.readFileSync(buildInfoPath));
|
buildInfo = JSON.parse(fs.readFileSync(buildInfoPath));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -74,11 +73,8 @@ function getBuildInfo() {
|
||||||
|
|
||||||
return buildInfo;
|
return buildInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildInfo = getBuildInfo();
|
const buildInfo = getBuildInfo();
|
||||||
|
|
||||||
console.log("build info", buildInfo);
|
|
||||||
|
|
||||||
function getRootHifiDataDirectory() {
|
function getRootHifiDataDirectory() {
|
||||||
var organization = "High Fidelity";
|
var organization = "High Fidelity";
|
||||||
if (buildInfo.releaseType != "PRODUCTION") {
|
if (buildInfo.releaseType != "PRODUCTION") {
|
||||||
|
@ -105,16 +101,26 @@ function getApplicationDataDirectory() {
|
||||||
return path.join(getRootHifiDataDirectory(), '/Server Console');
|
return path.join(getRootHifiDataDirectory(), '/Server Console');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Root hifi directory is: ", getRootHifiDataDirectory());
|
// Configure log
|
||||||
|
global.log = require('electron-log');
|
||||||
|
const logFile = getApplicationDataDirectory() + '/log.txt';
|
||||||
|
fs.ensureFileSync(logFile); // Ensure file exists
|
||||||
|
log.transports.file.maxSize = 5 * 1024 * 1024;
|
||||||
|
log.transports.file.file = logFile;
|
||||||
|
|
||||||
|
log.debug("build info", buildInfo);
|
||||||
|
log.debug("Root hifi directory is: ", getRootHifiDataDirectory());
|
||||||
|
|
||||||
const ipcMain = electron.ipcMain;
|
const ipcMain = electron.ipcMain;
|
||||||
|
|
||||||
|
|
||||||
var isShuttingDown = false;
|
var isShuttingDown = false;
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
|
log.debug("Normal shutdown (isShuttingDown: " + isShuttingDown + ")");
|
||||||
if (!isShuttingDown) {
|
if (!isShuttingDown) {
|
||||||
// if the home server is running, show a prompt before quit to ask if the user is sure
|
// if the home server is running, show a prompt before quit to ask if the user is sure
|
||||||
if (homeServer.state == ProcessGroupStates.STARTED) {
|
if (homeServer.state == ProcessGroupStates.STARTED) {
|
||||||
|
log.debug("Showing shutdown dialog.");
|
||||||
dialog.showMessageBox({
|
dialog.showMessageBox({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
buttons: ['Yes', 'No'],
|
buttons: ['Yes', 'No'],
|
||||||
|
@ -129,21 +135,26 @@ function shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function forcedShutdown() {
|
function forcedShutdown() {
|
||||||
|
log.debug("Forced shutdown (isShuttingDown: " + isShuttingDown + ")");
|
||||||
if (!isShuttingDown) {
|
if (!isShuttingDown) {
|
||||||
shutdownCallback(0);
|
shutdownCallback(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdownCallback(idx) {
|
function shutdownCallback(idx) {
|
||||||
|
log.debug("Entering shutdown callback.");
|
||||||
if (idx == 0 && !isShuttingDown) {
|
if (idx == 0 && !isShuttingDown) {
|
||||||
isShuttingDown = true;
|
isShuttingDown = true;
|
||||||
|
|
||||||
|
log.debug("Saving user config");
|
||||||
userConfig.save(configPath);
|
userConfig.save(configPath);
|
||||||
|
|
||||||
if (logWindow) {
|
if (logWindow) {
|
||||||
|
log.debug("Closing log window");
|
||||||
logWindow.close();
|
logWindow.close();
|
||||||
}
|
}
|
||||||
if (homeServer) {
|
if (homeServer) {
|
||||||
|
log.debug("Stoping home server");
|
||||||
homeServer.stop();
|
homeServer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,14 +162,17 @@ function shutdownCallback(idx) {
|
||||||
|
|
||||||
if (homeServer.state == ProcessGroupStates.STOPPED) {
|
if (homeServer.state == ProcessGroupStates.STOPPED) {
|
||||||
// if the home server is already down, take down the server console now
|
// if the home server is already down, take down the server console now
|
||||||
|
log.debug("Quitting.");
|
||||||
app.quit();
|
app.quit();
|
||||||
} else {
|
} else {
|
||||||
// if the home server is still running, wait until we get a state change or timeout
|
// if the home server is still running, wait until we get a state change or timeout
|
||||||
// before quitting the app
|
// before quitting the app
|
||||||
|
log.debug("Server still shutting down. Waiting");
|
||||||
var timeoutID = setTimeout(app.quit, 5000);
|
var timeoutID = setTimeout(app.quit, 5000);
|
||||||
homeServer.on('state-update', function(processGroup) {
|
homeServer.on('state-update', function(processGroup) {
|
||||||
if (processGroup.state == ProcessGroupStates.STOPPED) {
|
if (processGroup.state == ProcessGroupStates.STOPPED) {
|
||||||
clearTimeout(timeoutID);
|
clearTimeout(timeoutID);
|
||||||
|
log.debug("Quitting.");
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -167,36 +181,36 @@ function shutdownCallback(idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteOldFiles(directoryPath, maxAgeInSeconds, filenameRegex) {
|
function deleteOldFiles(directoryPath, maxAgeInSeconds, filenameRegex) {
|
||||||
console.log("Deleting old log files in " + directoryPath);
|
log.debug("Deleting old log files in " + directoryPath);
|
||||||
|
|
||||||
var filenames = [];
|
var filenames = [];
|
||||||
try {
|
try {
|
||||||
filenames = fs.readdirSync(directoryPath);
|
filenames = fs.readdirSync(directoryPath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Error reading contents of log file directory", e);
|
log.warn("Error reading contents of log file directory", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const filename of filenames) {
|
for (const filename of filenames) {
|
||||||
console.log("Checking", filename);
|
log.debug("Checking", filename);
|
||||||
const absolutePath = path.join(directoryPath, filename);
|
const absolutePath = path.join(directoryPath, filename);
|
||||||
var stat = null;
|
var stat = null;
|
||||||
try {
|
try {
|
||||||
stat = fs.statSync(absolutePath);
|
stat = fs.statSync(absolutePath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Error stat'ing file", absolutePath, e);
|
log.debug("Error stat'ing file", absolutePath, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const curTime = Date.now();
|
const curTime = Date.now();
|
||||||
if (stat.isFile() && filename.search(filenameRegex) >= 0) {
|
if (stat.isFile() && filename.search(filenameRegex) >= 0) {
|
||||||
const ageInSeconds = (curTime - stat.mtime.getTime()) / 1000.0;
|
const ageInSeconds = (curTime - stat.mtime.getTime()) / 1000.0;
|
||||||
if (ageInSeconds >= maxAgeInSeconds) {
|
if (ageInSeconds >= maxAgeInSeconds) {
|
||||||
console.log("\tDeleting:", filename, ageInSeconds);
|
log.debug("\tDeleting:", filename, ageInSeconds);
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(absolutePath);
|
fs.unlinkSync(absolutePath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code != 'EBUSY') {
|
if (e.code != 'EBUSY') {
|
||||||
console.warn("\tError deleting:", e);
|
log.warn("\tError deleting:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,8 +220,8 @@ function deleteOldFiles(directoryPath, maxAgeInSeconds, filenameRegex) {
|
||||||
|
|
||||||
var logPath = path.join(getApplicationDataDirectory(), '/logs');
|
var logPath = path.join(getApplicationDataDirectory(), '/logs');
|
||||||
|
|
||||||
console.log("Log directory:", logPath);
|
log.debug("Log directory:", logPath);
|
||||||
console.log("Data directory:", getRootHifiDataDirectory());
|
log.debug("Data directory:", getRootHifiDataDirectory());
|
||||||
|
|
||||||
const configPath = path.join(getApplicationDataDirectory(), 'config.json');
|
const configPath = path.join(getApplicationDataDirectory(), 'config.json');
|
||||||
var userConfig = new Config();
|
var userConfig = new Config();
|
||||||
|
@ -215,8 +229,8 @@ userConfig.load(configPath);
|
||||||
|
|
||||||
// print out uncaught exceptions in the console
|
// print out uncaught exceptions in the console
|
||||||
process.on('uncaughtException', function(err) {
|
process.on('uncaughtException', function(err) {
|
||||||
console.error(err);
|
log.error(err);
|
||||||
console.error(err.stack);
|
log.error(err.stack);
|
||||||
});
|
});
|
||||||
|
|
||||||
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
|
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
|
||||||
|
@ -225,7 +239,7 @@ var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (shouldQuit) {
|
if (shouldQuit) {
|
||||||
console.warn("Another instance of the Sandbox is already running - this instance will quit.");
|
log.warn("Another instance of the Sandbox is already running - this instance will quit.");
|
||||||
app.quit();
|
app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +520,7 @@ const httpStatusPort = 60332;
|
||||||
function backupResourceDirectories(folder) {
|
function backupResourceDirectories(folder) {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(folder);
|
fs.mkdirSync(folder);
|
||||||
console.log("Created directory " + folder);
|
log.debug("Created directory " + folder);
|
||||||
|
|
||||||
var dsBackup = path.join(folder, '/domain-server');
|
var dsBackup = path.join(folder, '/domain-server');
|
||||||
var acBackup = path.join(folder, '/assignment-client');
|
var acBackup = path.join(folder, '/assignment-client');
|
||||||
|
@ -519,7 +533,7 @@ function backupResourceDirectories(folder) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
log.debug(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +555,7 @@ function openBackupInstructions(folder) {
|
||||||
window.setSize(obj.width, obj.height);
|
window.setSize(obj.width, obj.height);
|
||||||
});
|
});
|
||||||
electron.ipcMain.on('ready', function() {
|
electron.ipcMain.on('ready', function() {
|
||||||
console.log("got ready");
|
log.debug("got ready");
|
||||||
window.webContents.send('update', folder);
|
window.webContents.send('update', folder);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -575,9 +589,9 @@ function checkNewContent() {
|
||||||
|
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
console.log('Last Modified: ' + response.headers['last-modified']);
|
log.debug('Last Modified: ' + response.headers['last-modified']);
|
||||||
console.log(localContent + " " + remoteContent + " " + shouldUpdate + " " + new Date());
|
log.debug(localContent + " " + remoteContent + " " + shouldUpdate + " " + new Date());
|
||||||
console.log("Remote content is " + (shouldUpdate ? "newer" : "older") + " that local content.");
|
log.debug("Remote content is " + (shouldUpdate ? "newer" : "older") + " that local content.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
|
@ -619,46 +633,46 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
// Check for existing data
|
// Check for existing data
|
||||||
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
||||||
|
|
||||||
console.log("Checking for existence of " + acResourceDirectory);
|
log.debug("Checking for existence of " + acResourceDirectory);
|
||||||
|
|
||||||
var userHasExistingACData = true;
|
var userHasExistingACData = true;
|
||||||
try {
|
try {
|
||||||
fs.accessSync(acResourceDirectory);
|
fs.accessSync(acResourceDirectory);
|
||||||
console.log("Found directory " + acResourceDirectory);
|
log.debug("Found directory " + acResourceDirectory);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
log.debug(e);
|
||||||
userHasExistingACData = false;
|
userHasExistingACData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dsResourceDirectory = getDomainServerClientResourcesDirectory();
|
const dsResourceDirectory = getDomainServerClientResourcesDirectory();
|
||||||
|
|
||||||
console.log("checking for existence of " + dsResourceDirectory);
|
log.debug("checking for existence of " + dsResourceDirectory);
|
||||||
|
|
||||||
var userHasExistingDSData = true;
|
var userHasExistingDSData = true;
|
||||||
try {
|
try {
|
||||||
fs.accessSync(dsResourceDirectory);
|
fs.accessSync(dsResourceDirectory);
|
||||||
console.log("Found directory " + dsResourceDirectory);
|
log.debug("Found directory " + dsResourceDirectory);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
log.debug(e);
|
||||||
userHasExistingDSData = false;
|
userHasExistingDSData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userHasExistingACData || userHasExistingDSData) {
|
if (userHasExistingACData || userHasExistingDSData) {
|
||||||
console.log("User has existing data, suppressing downloader");
|
log.debug("User has existing data, suppressing downloader");
|
||||||
onComplete();
|
onComplete();
|
||||||
|
|
||||||
checkNewContent();
|
checkNewContent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Found contentPath:" + argv.contentPath);
|
log.debug("Found contentPath:" + argv.contentPath);
|
||||||
if (argv.contentPath) {
|
if (argv.contentPath) {
|
||||||
fs.copy(argv.contentPath, getRootHifiDataDirectory(), function (err) {
|
fs.copy(argv.contentPath, getRootHifiDataDirectory(), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Could not copy home content: ' + err);
|
log.debug('Could not copy home content: ' + err);
|
||||||
return console.error(err)
|
return log.error(err)
|
||||||
}
|
}
|
||||||
console.log('Copied home content over to: ' + getRootHifiDataDirectory());
|
log.debug('Copied home content over to: ' + getRootHifiDataDirectory());
|
||||||
userConfig.set('homeContentLastModified', new Date());
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
onComplete();
|
onComplete();
|
||||||
});
|
});
|
||||||
|
@ -685,11 +699,11 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
window.on('closed', onComplete);
|
window.on('closed', onComplete);
|
||||||
|
|
||||||
electron.ipcMain.on('ready', function() {
|
electron.ipcMain.on('ready', function() {
|
||||||
console.log("got ready");
|
log.debug("got ready");
|
||||||
var currentState = '';
|
var currentState = '';
|
||||||
|
|
||||||
function sendStateUpdate(state, args) {
|
function sendStateUpdate(state, args) {
|
||||||
// console.log(state, window, args);
|
// log.debug(state, window, args);
|
||||||
window.webContents.send('update', { state: state, args: args });
|
window.webContents.send('update', { state: state, args: args });
|
||||||
currentState = state;
|
currentState = state;
|
||||||
}
|
}
|
||||||
|
@ -723,10 +737,10 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function extractError(err) {
|
function extractError(err) {
|
||||||
console.log("Aborting request because gunzip/untar failed");
|
log.debug("Aborting request because gunzip/untar failed");
|
||||||
aborted = true;
|
aborted = true;
|
||||||
req.abort();
|
req.abort();
|
||||||
console.log("ERROR" + err);
|
log.debug("ERROR" + err);
|
||||||
|
|
||||||
sendStateUpdate('error', {
|
sendStateUpdate('error', {
|
||||||
message: "Error installing resources."
|
message: "Error installing resources."
|
||||||
|
@ -738,7 +752,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
|
|
||||||
req.pipe(gunzip).pipe(tar.extract(getRootHifiDataDirectory())).on('error', extractError).on('finish', function(){
|
req.pipe(gunzip).pipe(tar.extract(getRootHifiDataDirectory())).on('error', extractError).on('finish', function(){
|
||||||
// response and decompression complete, return
|
// response and decompression complete, return
|
||||||
console.log("Finished unarchiving home content set");
|
log.debug("Finished unarchiving home content set");
|
||||||
userConfig.set('homeContentLastModified', new Date());
|
userConfig.set('homeContentLastModified', new Date());
|
||||||
sendStateUpdate('complete');
|
sendStateUpdate('complete');
|
||||||
});
|
});
|
||||||
|
@ -824,7 +838,7 @@ function onContentLoaded() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
notifier.on('click', function(notifierObject, options) {
|
notifier.on('click', function(notifierObject, options) {
|
||||||
console.log("Got click", options.url);
|
log.debug("Got click", options.url);
|
||||||
shell.openExternal(options.url);
|
shell.openExternal(options.url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -855,7 +869,7 @@ function onContentLoaded() {
|
||||||
// shutting down. The interface app will regularly update a running state file which we will check.
|
// shutting down. The interface app will regularly update a running state file which we will check.
|
||||||
// If the file doesn't exist or stops updating for a significant amount of time, we will shut down.
|
// If the file doesn't exist or stops updating for a significant amount of time, we will shut down.
|
||||||
if (argv.shutdownWatcher) {
|
if (argv.shutdownWatcher) {
|
||||||
console.log("Shutdown watcher requested... argv.shutdownWatcher:", argv.shutdownWatcher);
|
log.debug("Shutdown watcher requested... argv.shutdownWatcher:", argv.shutdownWatcher);
|
||||||
var MAX_TIME_SINCE_EDIT = 5000; // 5 seconds between updates
|
var MAX_TIME_SINCE_EDIT = 5000; // 5 seconds between updates
|
||||||
var firstAttemptToCheck = new Date().getTime();
|
var firstAttemptToCheck = new Date().getTime();
|
||||||
var shutdownWatchInterval = setInterval(function(){
|
var shutdownWatchInterval = setInterval(function(){
|
||||||
|
@ -863,14 +877,14 @@ function onContentLoaded() {
|
||||||
if (err) {
|
if (err) {
|
||||||
var sinceFirstCheck = new Date().getTime() - firstAttemptToCheck;
|
var sinceFirstCheck = new Date().getTime() - firstAttemptToCheck;
|
||||||
if (sinceFirstCheck > MAX_TIME_SINCE_EDIT) {
|
if (sinceFirstCheck > MAX_TIME_SINCE_EDIT) {
|
||||||
console.log("Running state file is missing, assume interface has shutdown... shutting down snadbox.");
|
log.debug("Running state file is missing, assume interface has shutdown... shutting down snadbox.");
|
||||||
forcedShutdown();
|
forcedShutdown();
|
||||||
clearTimeout(shutdownWatchInterval);
|
clearTimeout(shutdownWatchInterval);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var sinceEdit = new Date().getTime() - stats.mtime.getTime();
|
var sinceEdit = new Date().getTime() - stats.mtime.getTime();
|
||||||
if (sinceEdit > MAX_TIME_SINCE_EDIT) {
|
if (sinceEdit > MAX_TIME_SINCE_EDIT) {
|
||||||
console.log("Running state of interface hasn't updated in MAX time... shutting down.");
|
log.debug("Running state of interface hasn't updated in MAX time... shutting down.");
|
||||||
forcedShutdown();
|
forcedShutdown();
|
||||||
clearTimeout(shutdownWatchInterval);
|
clearTimeout(shutdownWatchInterval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ Config.prototype = {
|
||||||
try {
|
try {
|
||||||
rawData = fs.readFileSync(filePath);
|
rawData = fs.readFileSync(filePath);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Config file not found");
|
log.debug("Config file not found");
|
||||||
}
|
}
|
||||||
var configData = {};
|
var configData = {};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ Config.prototype = {
|
||||||
configData = {};
|
configData = {};
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error("Error parsing config file", filePath)
|
log.error("Error parsing config file", filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data = {};
|
this.data = {};
|
||||||
|
@ -37,7 +37,7 @@ Config.prototype = {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
},
|
},
|
||||||
set: function(key, value) {
|
set: function(key, value) {
|
||||||
console.log("Setting", key, "to", value);
|
log.debug("Setting", key, "to", value);
|
||||||
this.data[key] = value;
|
this.data[key] = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
36
server-console/src/modules/hf-process.js
Executable file → Normal file
36
server-console/src/modules/hf-process.js
Executable file → Normal file
|
@ -43,7 +43,7 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, {
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
if (this.state != ProcessGroupStates.STOPPED) {
|
if (this.state != ProcessGroupStates.STOPPED) {
|
||||||
console.warn("Can't start process group that is not stopped.");
|
log.warn("Can't start process group that is not stopped.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, {
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function() {
|
||||||
if (this.state != ProcessGroupStates.STARTED) {
|
if (this.state != ProcessGroupStates.STARTED) {
|
||||||
console.warn("Can't stop process group that is not started.");
|
log.warn("Can't stop process group that is not started.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let process of this.processes) {
|
for (let process of this.processes) {
|
||||||
|
@ -120,10 +120,10 @@ util.inherits(Process, events.EventEmitter);
|
||||||
Process.prototype = extend(Process.prototype, {
|
Process.prototype = extend(Process.prototype, {
|
||||||
start: function() {
|
start: function() {
|
||||||
if (this.state != ProcessStates.STOPPED) {
|
if (this.state != ProcessStates.STOPPED) {
|
||||||
console.warn("Can't start process that is not stopped.");
|
log.warn("Can't start process that is not stopped.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Starting " + this.command + " " + this.commandArgs.join(' '));
|
log.debug("Starting " + this.command + " " + this.commandArgs.join(' '));
|
||||||
|
|
||||||
var logStdout = 'ignore',
|
var logStdout = 'ignore',
|
||||||
logStderr = 'ignore';
|
logStderr = 'ignore';
|
||||||
|
@ -138,7 +138,7 @@ Process.prototype = extend(Process.prototype, {
|
||||||
if (e.code == 'EEXIST') {
|
if (e.code == 'EEXIST') {
|
||||||
logDirectoryCreated = true;
|
logDirectoryCreated = true;
|
||||||
} else {
|
} else {
|
||||||
console.error("Error creating log directory");
|
log.error("Error creating log directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,13 +151,13 @@ Process.prototype = extend(Process.prototype, {
|
||||||
try {
|
try {
|
||||||
logStdout = fs.openSync(tmpLogStdout, 'ax');
|
logStdout = fs.openSync(tmpLogStdout, 'ax');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Error creating stdout log file", e);
|
log.debug("Error creating stdout log file", e);
|
||||||
logStdout = 'ignore';
|
logStdout = 'ignore';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
logStderr = fs.openSync(tmpLogStderr, 'ax');
|
logStderr = fs.openSync(tmpLogStderr, 'ax');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Error creating stderr log file", e);
|
log.debug("Error creating stderr log file", e);
|
||||||
logStderr = 'ignore';
|
logStderr = 'ignore';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ Process.prototype = extend(Process.prototype, {
|
||||||
stdio: ['ignore', logStdout, logStderr]
|
stdio: ['ignore', logStdout, logStderr]
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Got error starting child process for " + this.name, e);
|
log.debug("Got error starting child process for " + this.name, e);
|
||||||
this.child = null;
|
this.child = null;
|
||||||
this.updateState(ProcessStates.STOPPED);
|
this.updateState(ProcessStates.STOPPED);
|
||||||
return;
|
return;
|
||||||
|
@ -179,7 +179,7 @@ Process.prototype = extend(Process.prototype, {
|
||||||
var pidLogStdout = path.resolve(this.logDirectory + '/' + this.name + "-" + this.child.pid + "-" + time + "-stdout.txt");
|
var pidLogStdout = path.resolve(this.logDirectory + '/' + this.name + "-" + this.child.pid + "-" + time + "-stdout.txt");
|
||||||
fs.rename(tmpLogStdout, pidLogStdout, function(e) {
|
fs.rename(tmpLogStdout, pidLogStdout, function(e) {
|
||||||
if (e !== null) {
|
if (e !== null) {
|
||||||
console.log("Error renaming log file from " + tmpLogStdout + " to " + pidLogStdout, e);
|
log.debug("Error renaming log file from " + tmpLogStdout + " to " + pidLogStdout, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.logStdout = pidLogStdout;
|
this.logStdout = pidLogStdout;
|
||||||
|
@ -190,7 +190,7 @@ Process.prototype = extend(Process.prototype, {
|
||||||
var pidLogStderr = path.resolve(this.logDirectory + '/' + this.name + "-" + this.child.pid + "-" + time + "-stderr.txt");
|
var pidLogStderr = path.resolve(this.logDirectory + '/' + this.name + "-" + this.child.pid + "-" + time + "-stderr.txt");
|
||||||
fs.rename(tmpLogStderr, pidLogStderr, function(e) {
|
fs.rename(tmpLogStderr, pidLogStderr, function(e) {
|
||||||
if (e !== null) {
|
if (e !== null) {
|
||||||
console.log("Error renaming log file from " + tmpLogStdout + " to " + pidLogStdout, e);
|
log.debug("Error renaming log file from " + tmpLogStdout + " to " + pidLogStdout, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.logStderr = pidLogStderr;
|
this.logStderr = pidLogStderr;
|
||||||
|
@ -201,13 +201,13 @@ Process.prototype = extend(Process.prototype, {
|
||||||
this.child.on('error', this.onChildStartError.bind(this));
|
this.child.on('error', this.onChildStartError.bind(this));
|
||||||
this.child.on('close', this.onChildClose.bind(this));
|
this.child.on('close', this.onChildClose.bind(this));
|
||||||
|
|
||||||
console.log("Child process started");
|
log.debug("Child process started");
|
||||||
this.updateState(ProcessStates.STARTED);
|
this.updateState(ProcessStates.STARTED);
|
||||||
this.emit('logs-updated');
|
this.emit('logs-updated');
|
||||||
},
|
},
|
||||||
stop: function(force) {
|
stop: function(force) {
|
||||||
if (this.state == ProcessStates.STOPPED) {
|
if (this.state == ProcessStates.STOPPED) {
|
||||||
console.warn("Can't stop process that is not started or stopping.");
|
log.warn("Can't stop process that is not started or stopping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (os.type() == "Windows_NT") {
|
if (os.type() == "Windows_NT") {
|
||||||
|
@ -217,7 +217,7 @@ Process.prototype = extend(Process.prototype, {
|
||||||
}
|
}
|
||||||
childProcess.exec(command, {}, function(error) {
|
childProcess.exec(command, {}, function(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error executing taskkill:', error);
|
log.error('Error executing taskkill:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,12 +225,12 @@ Process.prototype = extend(Process.prototype, {
|
||||||
this.child.kill(signal);
|
this.child.kill(signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Stopping child process:", this.child.pid, this.name);
|
log.debug("Stopping child process:", this.child.pid, this.name);
|
||||||
|
|
||||||
if (!force) {
|
if (!force) {
|
||||||
this.stoppingTimeoutID = setTimeout(function() {
|
this.stoppingTimeoutID = setTimeout(function() {
|
||||||
if (this.state == ProcessStates.STOPPING) {
|
if (this.state == ProcessStates.STOPPING) {
|
||||||
console.log("Force killling", this.name, this.child.pid);
|
log.debug("Force killling", this.name, this.child.pid);
|
||||||
this.stop(true);
|
this.stop(true);
|
||||||
}
|
}
|
||||||
}.bind(this), 2500);
|
}.bind(this), 2500);
|
||||||
|
@ -257,11 +257,11 @@ Process.prototype = extend(Process.prototype, {
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
onChildStartError: function(error) {
|
onChildStartError: function(error) {
|
||||||
console.log("Child process error ", error);
|
log.debug("Child process error ", error);
|
||||||
this.updateState(ProcessStates.STOPPED);
|
this.updateState(ProcessStates.STOPPED);
|
||||||
},
|
},
|
||||||
onChildClose: function(code) {
|
onChildClose: function(code) {
|
||||||
console.log("Child process closed with code ", code, this.name);
|
log.debug("Child process closed with code ", code, this.name);
|
||||||
if (this.stoppingTimeoutID) {
|
if (this.stoppingTimeoutID) {
|
||||||
clearTimeout(this.stoppingTimeoutID);
|
clearTimeout(this.stoppingTimeoutID);
|
||||||
this.stoppingTimeoutID = null;
|
this.stoppingTimeoutID = null;
|
||||||
|
@ -332,7 +332,7 @@ ACMonitorProcess.prototype = extend(ACMonitorProcess.prototype, {
|
||||||
this.pendingRequest = null;
|
this.pendingRequest = null;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('ERROR Getting AC Monitor status', error);
|
log.error('ERROR Getting AC Monitor status', error);
|
||||||
} else {
|
} else {
|
||||||
this.childServers = body.servers;
|
this.childServers = body.servers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ const BUILDS_URL = 'https://highfidelity.com/builds.xml';
|
||||||
|
|
||||||
function UpdateChecker(currentVersion, checkForUpdatesEveryXSeconds) {
|
function UpdateChecker(currentVersion, checkForUpdatesEveryXSeconds) {
|
||||||
this.currentVersion = currentVersion;
|
this.currentVersion = currentVersion;
|
||||||
console.log('cur', currentVersion);
|
log.debug('cur', currentVersion);
|
||||||
|
|
||||||
setInterval(this.checkForUpdates.bind(this), checkForUpdatesEveryXSeconds * 1000);
|
setInterval(this.checkForUpdates.bind(this), checkForUpdatesEveryXSeconds * 1000);
|
||||||
this.checkForUpdates();
|
this.checkForUpdates();
|
||||||
|
@ -19,10 +19,10 @@ function UpdateChecker(currentVersion, checkForUpdatesEveryXSeconds) {
|
||||||
util.inherits(UpdateChecker, events.EventEmitter);
|
util.inherits(UpdateChecker, events.EventEmitter);
|
||||||
UpdateChecker.prototype = extend(UpdateChecker.prototype, {
|
UpdateChecker.prototype = extend(UpdateChecker.prototype, {
|
||||||
checkForUpdates: function() {
|
checkForUpdates: function() {
|
||||||
console.log("Checking for updates");
|
log.debug("Checking for updates");
|
||||||
request(BUILDS_URL, (error, response, body) => {
|
request(BUILDS_URL, (error, response, body) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("Error", error);
|
log.debug("Error", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -30,13 +30,13 @@ UpdateChecker.prototype = extend(UpdateChecker.prototype, {
|
||||||
var $ = cheerio.load(body, { xmlMode: true });
|
var $ = cheerio.load(body, { xmlMode: true });
|
||||||
const latestBuild = $('project[name="interface"] platform[name="' + platform + '"]').children().first();
|
const latestBuild = $('project[name="interface"] platform[name="' + platform + '"]').children().first();
|
||||||
const latestVersion = parseInt(latestBuild.find('version').text());
|
const latestVersion = parseInt(latestBuild.find('version').text());
|
||||||
console.log("Latest version is:", latestVersion, this.currentVersion);
|
log.debug("Latest version is:", latestVersion, this.currentVersion);
|
||||||
if (latestVersion > this.currentVersion) {
|
if (latestVersion > this.currentVersion) {
|
||||||
const url = latestBuild.find('url').text();
|
const url = latestBuild.find('url').text();
|
||||||
this.emit('update-available', latestVersion, url);
|
this.emit('update-available', latestVersion, url);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Error when checking for updates", e);
|
log.warn("Error when checking for updates", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,11 +72,11 @@ exports.discoveredPath = function (name, binaryType, releaseType) {
|
||||||
var extension = platformExtension(name);
|
var extension = platformExtension(name);
|
||||||
|
|
||||||
if (stats.isFile() || (stats.isDirectory() && extension == ".app")) {
|
if (stats.isFile() || (stats.isDirectory() && extension == ".app")) {
|
||||||
console.log("Found " + name + " at " + testPath);
|
log.debug("Found " + name + " at " + testPath);
|
||||||
return testPath;
|
return testPath;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Executable with name " + name + " not found at path " + testPath);
|
log.debug("Executable with name " + name + " not found at path " + testPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
45
unpublishedScripts/DomainContent/Home/portal.js
Normal file
45
unpublishedScripts/DomainContent/Home/portal.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
(function(){
|
||||||
|
var teleport;
|
||||||
|
var portalDestination;
|
||||||
|
|
||||||
|
function playSound() {
|
||||||
|
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
this.preload = function(entityID) {
|
||||||
|
teleport = SoundCache.getSound("atp:/sounds/teleport.raw");
|
||||||
|
|
||||||
|
var properties = Entities.getEntityProperties(entityID);
|
||||||
|
portalDestination = properties.userData;
|
||||||
|
|
||||||
|
print("portal.js | The portal destination is " + portalDestination);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.enterEntity = function(entityID) {
|
||||||
|
print("portal.js | enterEntity");
|
||||||
|
|
||||||
|
var properties = Entities.getEntityProperties(entityID); // in case the userData/portalURL has changed
|
||||||
|
portalDestination = properties.userData;
|
||||||
|
|
||||||
|
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
||||||
|
|
||||||
|
if (portalDestination.length > 0) {
|
||||||
|
if (portalDestination[0] == '/') {
|
||||||
|
print("Teleporting to " + portalDestination);
|
||||||
|
Window.location = portalDestination;
|
||||||
|
} else {
|
||||||
|
print("Teleporting to hifi://" + portalDestination);
|
||||||
|
Window.location = "hifi://" + portalDestination;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
location.goToEntry(); // going forward: no data means go to appropriate entry point
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
this.leaveEntity = function(entityID) {
|
||||||
|
print("portal.js | leaveEntity");
|
||||||
|
|
||||||
|
playSound();
|
||||||
|
};
|
||||||
|
})
|
Loading…
Reference in a new issue