error state signal for 404/interstitial

This commit is contained in:
Wayne Chen 2018-09-26 13:48:15 -07:00
parent 4a87773986
commit db41a1c16b
8 changed files with 78 additions and 33 deletions

View file

@ -172,7 +172,7 @@ bool SafeLanding::isEntityLoadingComplete() {
bool isVisuallyReady = true;
Settings settings;
bool enableInterstitial = settings.value("enableIntersitialMode", false).toBool();
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
if (enableInterstitial) {
isVisuallyReady = (entity->isVisuallyReady() || !entityTree->renderableForEntityId(entityMapIter->first));

View file

@ -39,6 +39,7 @@ WindowScriptingInterface::WindowScriptingInterface() {
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &WindowScriptingInterface::disconnectedFromDomain);
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
connect(&domainHandler, &DomainHandler::redirectErrorStateChanged, this, &WindowScriptingInterface::redirectErrorStateChanged);
connect(qApp, &Application::svoImportRequested, [this](const QString& urlString) {
static const QMetaMethod svoImportRequestedSignal =

View file

@ -611,6 +611,14 @@ signals:
*/
void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo);
/**jsdoc
* Triggered when you try to visit a domain but are redirected into the error state.
* @function Window.redirectErrorStateChanged
* @param {boolean} isInErrorState - If <code>true</code>, the user has been redirected to the error URL.
* @returns {Signal}
*/
void redirectErrorStateChanged(bool isInErrorState);
/**jsdoc
* Triggered when a still snapshot has been taken by calling {@link Window.takeSnapshot|takeSnapshot} with
* <code>includeAnimated = false</code> or {@link Window.takeSecondaryCameraSnapshot|takeSecondaryCameraSnapshot}.

View file

@ -123,6 +123,7 @@ void DomainHandler::hardReset() {
softReset();
_isInErrorState = false;
emit redirectErrorStateChanged(_isInErrorState);
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
_pendingDomainID = QUuid();
@ -362,6 +363,7 @@ void DomainHandler::setRedirectErrorState(QUrl errorUrl, QString reasonMessage,
if (getInterstitialModeEnabled()) {
_errorDomainURL = errorUrl;
_isInErrorState = true;
emit redirectErrorStateChanged(_isInErrorState);
emit redirectToErrorDomainURL(_errorDomainURL);
} else {
emit domainConnectionRefused(reasonMessage, reasonCode, extraInfo);

View file

@ -187,8 +187,6 @@ private slots:
signals:
void domainURLChanged(QUrl domainURL);
void domainConnectionErrorChanged(int reasonCode);
// NOTE: the emission of completedSocketDiscovery does not mean a connection to DS is established
// It means that, either from DNS lookup or ICE, we think we have a socket we can talk to DS on
void completedSocketDiscovery();
@ -205,6 +203,7 @@ signals:
void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo);
void redirectToErrorDomainURL(QUrl errorDomainURL);
void redirectErrorStateChanged(bool isInErrorState);
void limitOfSilentDomainCheckInsReached();

View file

@ -38,7 +38,7 @@ var DEFAULT_SCRIPTS_SEPARATE = [
//"system/chat.js"
];
if (Settings.getValue("enableInterstitialMode", false)) {
if (Window.interstitialModeEnabled) {
DEFAULT_SCRIPTS_SEPARATE.push("system/interstitialPage.js");
DEFAULT_SCRIPTS_SEPARATE.push("system/redirectOverlays.js");
}

View file

@ -37,6 +37,8 @@
var tablet = null;
var button = null;
var errorConnectingToDomain = false;
// Tips have a character limit of 69
var userTips = [
"Tip: Visit TheSpot to explore featured domains!",
@ -188,6 +190,16 @@
var connectionToDomainFailed = false;
function getOopsText() {
var error = Window.getLastDomainConnectionError();
var errorMessageMapIndex = hardRefusalErrors.indexOf(error);
if (errorMessageMapIndex >= 0) {
return ERROR_MESSAGE_MAP[errorMessageMapIndex];
} else {
// some other text.
return ERROR_MESSAGE_MAP[4];
}
}
function getAnchorLocalYOffset() {
var loadingSpherePosition = Overlays.getProperty(loadingSphereID, "position");
@ -235,6 +247,13 @@
}
}
function toggleInterstitialPage(isInErrorState) {
errorConnectingToDomain = isInErrorState;
if (!errorConnectingToDomain) {
domainChanged(location);
}
}
function startAudio() {
sample = Audio.playSound(tune, {
localOnly: true,
@ -347,9 +366,11 @@
Overlays.editOverlay(loadingBarPlacard, properties);
Overlays.editOverlay(loadingBarProgress, loadingBarProperties);
Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
if (!HMD.active) {
toolbar.writeProperty("visible", physicsEnabled);
if (errorConnectingToDomain) {
Menu.setIsOptionChecked("Show Overlays", physicsEnabled);
if (!HMD.active) {
toolbar.writeProperty("visible", physicsEnabled);
}
}
resetValues();
@ -359,7 +380,6 @@
}
}
function scaleInterstitialPage(sensorToWorldScale) {
var yOffset = getAnchorLocalYOffset();
var localPosition = {
@ -399,14 +419,19 @@
Overlays.editOverlay(loadingBarProgress, properties);
if ((physicsEnabled && (currentProgress >= (TOTAL_LOADING_PROGRESS - EPSILON)))) {
if (errorConnectingToDomain) {
updateOverlays(errorConnectingToDomain);
endAudio();
currentDomain = "no domain";
timer = null;
return;
} else if ((physicsEnabled && (currentProgress >= (TOTAL_LOADING_PROGRESS - EPSILON)))) {
updateOverlays((physicsEnabled || connectionToDomainFailed));
endAudio();
currentDomain = "no domain";
timer = null;
return;
}
timer = Script.setTimeout(update, BASIC_TIMER_INTERVAL_MS);
}
var whiteColor = {red: 255, green: 255, blue: 255};
@ -430,6 +455,7 @@
connectionToDomainFailed = !location.isConnected;
}, 1200);
});
Window.redirectErrorStateChanged.connect(toggleInterstitialPage);
MyAvatar.sensorToWorldScaleChanged.connect(scaleInterstitialPage);
MyAvatar.sessionUUIDChanged.connect(function() {

View file

@ -13,11 +13,10 @@
var TIMEOUT = 5;
var hardRefusalErrors = [PROTOCOL_VERSION_MISMATCH,
NOT_AUTHORIZED, TIMEOUT];
var error = -1;
var timer = null;
function getOopsText() {
error = Window.getLastDomainConnectionError();
var error = Window.getLastDomainConnectionError();
var errorMessageMapIndex = hardRefusalErrors.indexOf(error);
if (errorMessageMapIndex >= 0) {
return ERROR_MESSAGE_MAP[errorMessageMapIndex];
@ -29,58 +28,68 @@
var redirectOopsText = Overlays.addOverlay("text3d", {
name: "oopsText",
localPosition: {x: 0.5691902160644531, y: 0.6403706073760986, z: 6.68358039855957},
localPosition: {x: 0.2691902160644531, y: 0.6403706073760986, z: 3.18358039855957},
localRotation: Quat.fromPitchYawRollDegrees(0.0, 180.0, 0.0),
text: getOopsText(),
textAlpha: 1,
backgroundAlpha: 0,
color: {x: 255, y: 255, z: 255},
lineHeight: 0.10,
leftMargin: 0.538373570564886,
visible: false,
emissive: true,
ignoreRayIntersection: false,
drawInFront: true,
dimensions: {x: 4.2, y: 1},
grabbable: false,
orientation: {x: 0.0, y: 0.5, z: 0.0, w: 0.87},
parentID: MyAvatar.SELF_ID,
parentJointIndex: MyAvatar.getJointIndex("Head")
});
var tryAgainImage = Overlays.addOverlay("image3d", {
name: "tryAgainImage",
localPosition: {x: -0.15, y: -0.4, z: 0.0},
localPosition: {x: -0.6, y: -0.4, z: 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button_tryAgain.png",
alpha: 1,
visible: false,
emissive: true,
ignoreRayIntersection: false,
drawInFront: true,
grabbable: false,
orientation: {x: 0.0, y: 0.5, z: 0, w: 0.87},
orientation: Overlays.getProperty(redirectOopsText, "orientation"),
parentID: redirectOopsText
});
var backImage = Overlays.addOverlay("image3d", {
name: "backImage",
localPosition: {x: 1.0, y: -0.4, z: 0.0},
localPosition: {x: 0.6, y: -0.4, z: 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button_back.png",
alpha: 1,
visible: false,
emissive: true,
ignoreRayIntersection: false,
drawInFront: true,
grabbable: false,
orientation: {x: 0.0, y: 0.5, z: 0, w: 0.87},
orientation: Overlays.getProperty(redirectOopsText, "orientation"),
parentID: redirectOopsText
});
var TARGET_UPDATE_HZ = 60;
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
function toggleOverlays() {
function toggleOverlays(isInErrorState) {
if (!isInErrorState) {
var properties = {
visible: false
};
Overlays.editOverlay(redirectOopsText, properties);
Overlays.editOverlay(tryAgainImage, properties);
Overlays.editOverlay(backImage, properties);
return;
}
var overlaysVisible = false;
error = Window.getLastDomainConnectionError();
var error = Window.getLastDomainConnectionError();
var errorMessageMapIndex = hardRefusalErrors.indexOf(error);
var oopsText = "";
if (error === -1 || !Window.isPhysicsEnabled() || location.isConnected) {
if (error === -1) {
overlaysVisible = false;
} else if (errorMessageMapIndex >= 0) {
overlaysVisible = true;
@ -93,28 +102,27 @@
visible: overlaysVisible
};
var textWidth = Overlays.textSize(redirectOopsText, oopsText).width;
var textOverlayWidth = Overlays.getProperty(redirectOopsText, "dimensions").x;
var oopsTextProperties = {
visible: overlaysVisible,
text: oopsText
text: oopsText,
leftMargin: (textOverlayWidth - textWidth) / 2
};
Overlays.editOverlay(redirectOopsText, oopsTextProperties);
Overlays.editOverlay(tryAgainImage, properties);
Overlays.editOverlay(backImage, properties);
}
function clickedOnOverlay(overlayID, event) {
var properties = {
visible: false
};
if (tryAgainImage === overlayID) {
location.goToLastAddress();
} else if (backImage === overlayID) {
location.goBack();
}
Overlays.editOverlay(redirectOopsText, properties);
Overlays.editOverlay(tryAgainImage, properties);
Overlays.editOverlay(backImage, properties);
}
function cleanup() {
@ -125,6 +133,8 @@
Overlays.deleteOverlay(backImage);
}
toggleOverlays(true);
var whiteColor = {red: 255, green: 255, blue: 255};
var greyColor = {red: 125, green: 125, blue: 125};
Overlays.mouseReleaseOnOverlay.connect(clickedOnOverlay);
@ -140,8 +150,7 @@
}
});
timer = Script.setInterval(toggleOverlays, 500);
// Script.update.connect(toggleOverlays);
Window.redirectErrorStateChanged.connect(toggleOverlays);
Script.scriptEnding.connect(cleanup);
}());