diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index c9d7ea77d5..84408d2e9a 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -380,6 +380,14 @@ "default": "0", "advanced": false }, + { + "name": "maximum_user_capacity_redirect_location", + "label": "Redirect to Location on Maximum Capacity", + "help": "Is there another domain, you'd like to redirect clients to when the maximum number of avatars are connected.", + "placeholder": "", + "default": "", + "advanced": false + }, { "name": "standard_permissions", "type": "table", diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 23a53c3eb0..e33cbe1755 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -317,6 +317,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo } const QString MAXIMUM_USER_CAPACITY = "security.maximum_user_capacity"; +const QString MAXIMUM_USER_CAPACITY_REDIRECT_LOCATION = "security.maximum_user_capacity_redirect_location"; SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnectionData& nodeConnection, const QString& username, @@ -363,7 +364,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect if (!userPerms.can(NodePermissions::Permission::canConnectToDomain)) { sendConnectionDeniedPacket("You lack the required permissions to connect to this domain.", - nodeConnection.senderSockAddr, DomainHandler::ConnectionRefusedReason::TooManyUsers); + nodeConnection.senderSockAddr, DomainHandler::ConnectionRefusedReason::NotAuthorized); #ifdef WANT_DEBUG qDebug() << "stalling login due to permissions:" << username; #endif @@ -372,8 +373,16 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect if (!userPerms.can(NodePermissions::Permission::canConnectPastMaxCapacity) && !isWithinMaxCapacity()) { // we can't allow this user to connect because we are at max capacity + QString redirectOnMaxCapacity; + const QVariant* redirectOnMaxCapacityVariant = + valueForKeyPath(_server->_settingsManager.getSettingsMap(), MAXIMUM_USER_CAPACITY_REDIRECT_LOCATION); + if (redirectOnMaxCapacityVariant && redirectOnMaxCapacityVariant->canConvert()) { + redirectOnMaxCapacity = redirectOnMaxCapacityVariant->toString(); + qDebug() << "Redirection domain:" << redirectOnMaxCapacity; + } + sendConnectionDeniedPacket("Too many connected users.", nodeConnection.senderSockAddr, - DomainHandler::ConnectionRefusedReason::TooManyUsers); + DomainHandler::ConnectionRefusedReason::TooManyUsers, redirectOnMaxCapacity); #ifdef WANT_DEBUG qDebug() << "stalling login due to max capacity:" << username; #endif @@ -623,22 +632,30 @@ void DomainGatekeeper::sendProtocolMismatchConnectionDenial(const HifiSockAddr& } void DomainGatekeeper::sendConnectionDeniedPacket(const QString& reason, const HifiSockAddr& senderSockAddr, - DomainHandler::ConnectionRefusedReason reasonCode) { + DomainHandler::ConnectionRefusedReason reasonCode, + QString extraInfo) { // this is an agent and we've decided we won't let them connect - send them a packet to deny connection - QByteArray utfString = reason.toUtf8(); - quint16 payloadSize = utfString.size(); + QByteArray utfReasonString = reason.toUtf8(); + quint16 reasonSize = utfReasonString.size(); + + QByteArray utfExtraInfo = extraInfo.toUtf8(); + quint16 extraInfoSize = utfExtraInfo.size(); // setup the DomainConnectionDenied packet auto connectionDeniedPacket = NLPacket::create(PacketType::DomainConnectionDenied, - payloadSize + sizeof(payloadSize) + sizeof(uint8_t)); + sizeof(uint8_t) + // reasonCode + reasonSize + sizeof(reasonSize) + + extraInfoSize + sizeof(extraInfoSize)); // pack in the reason the connection was denied (the client displays this) - if (payloadSize > 0) { - uint8_t reasonCodeWire = (uint8_t)reasonCode; - connectionDeniedPacket->writePrimitive(reasonCodeWire); - connectionDeniedPacket->writePrimitive(payloadSize); - connectionDeniedPacket->write(utfString); - } + uint8_t reasonCodeWire = (uint8_t)reasonCode; + connectionDeniedPacket->writePrimitive(reasonCodeWire); + connectionDeniedPacket->writePrimitive(reasonSize); + connectionDeniedPacket->write(utfReasonString); + + // write the extra info as well + connectionDeniedPacket->writePrimitive(extraInfoSize); + connectionDeniedPacket->write(utfExtraInfo); // send the packet off DependencyManager::get()->sendPacket(std::move(connectionDeniedPacket), senderSockAddr); diff --git a/domain-server/src/DomainGatekeeper.h b/domain-server/src/DomainGatekeeper.h index 06ecfcf285..b7d2a03af6 100644 --- a/domain-server/src/DomainGatekeeper.h +++ b/domain-server/src/DomainGatekeeper.h @@ -88,7 +88,8 @@ private: void sendConnectionTokenPacket(const QString& username, const HifiSockAddr& senderSockAddr); static void sendConnectionDeniedPacket(const QString& reason, const HifiSockAddr& senderSockAddr, - DomainHandler::ConnectionRefusedReason reasonCode = DomainHandler::ConnectionRefusedReason::Unknown); + DomainHandler::ConnectionRefusedReason reasonCode = DomainHandler::ConnectionRefusedReason::Unknown, + QString extraInfo = QString()); void pingPunchForConnectingPeer(const SharedNetworkPeer& peer); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8a37662ca9..97a10ea232 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1239,8 +1239,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : firstRun.set(false); } -void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCode) { - switch (static_cast(reasonCode)) { +void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { + DomainHandler::ConnectionRefusedReason reasonCode = static_cast(reasonCodeInt); + + if (reasonCode == DomainHandler::ConnectionRefusedReason::TooManyUsers && !extraInfo.isEmpty()) { + DependencyManager::get()->handleLookupString(extraInfo); + return; + } + + switch (reasonCode) { case DomainHandler::ConnectionRefusedReason::ProtocolMismatch: case DomainHandler::ConnectionRefusedReason::TooManyUsers: case DomainHandler::ConnectionRefusedReason::Unknown: { diff --git a/interface/src/Application.h b/interface/src/Application.h index 02682defca..4c52ff8526 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -375,7 +375,7 @@ private slots: void nodeKilled(SharedNodePointer node); static void packetSent(quint64 length); void updateDisplayMode(); - void domainConnectionRefused(const QString& reasonMessage, int reason); + void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo); private: static void initDisplay(); diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 715d0657a3..9303636a1f 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -58,7 +58,7 @@ public slots: signals: void domainChanged(const QString& domainHostname); void svoImportRequested(const QString& url); - void domainConnectionRefused(const QString& reasonMessage, int reasonCode); + void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); void snapshotTaken(const QString& path, bool notify); void snapshotShared(const QString& error); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 2a0094de29..ab9cc45740 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -278,12 +278,18 @@ void setupPreferences() { preferences->addPreference(preference); } #if DEV_BUILD || PR_BUILD + { + auto getter = []()->bool { return DependencyManager::get()->isSimulatingJitter(); }; + auto setter = [](bool value) { return DependencyManager::get()->setIsSimulatingJitter(value); }; + auto preference = new CheckPreference(AUDIO, "Packet jitter simulator", getter, setter); + preferences->addPreference(preference); + } { auto getter = []()->float { return DependencyManager::get()->getGateThreshold(); }; auto setter = [](float value) { return DependencyManager::get()->setGateThreshold(value); }; - auto preference = new SpinnerPreference(AUDIO, "Debug gate threshold", getter, setter); + auto preference = new SpinnerPreference(AUDIO, "Packet throttle threshold", getter, setter); preference->setMin(1); - preference->setMax((float)100); + preference->setMax(200); preference->setStep(1); preferences->addPreference(preference); } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index a37a208072..b03672063f 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -56,8 +56,6 @@ static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100; static const auto DEFAULT_POSITION_GETTER = []{ return Vectors::ZERO; }; static const auto DEFAULT_ORIENTATION_GETTER = [] { return Quaternions::IDENTITY; }; -static const int DEFAULT_AUDIO_OUTPUT_GATE_THRESHOLD = 1; - Setting::Handle dynamicJitterBuffers("dynamicJitterBuffers", DEFAULT_DYNAMIC_JITTER_BUFFERS); Setting::Handle maxFramesOverDesired("maxFramesOverDesired", DEFAULT_MAX_FRAMES_OVER_DESIRED); Setting::Handle staticDesiredJitterBufferFrames("staticDesiredJitterBufferFrames", @@ -102,8 +100,7 @@ private: AudioClient::AudioClient() : AbstractAudioInterface(), - _gateThreshold("audioOutputGateThreshold", DEFAULT_AUDIO_OUTPUT_GATE_THRESHOLD), - _gate(this, _gateThreshold.get()), + _gate(this), _audioInput(NULL), _desiredInputFormat(), _inputFormat(), @@ -551,31 +548,53 @@ void AudioClient::handleAudioDataPacket(QSharedPointer message) } } -AudioClient::Gate::Gate(AudioClient* audioClient, int threshold) : - _audioClient(audioClient), - _threshold(threshold) {} +AudioClient::Gate::Gate(AudioClient* audioClient) : + _audioClient(audioClient) {} + +void AudioClient::Gate::setIsSimulatingJitter(bool enable) { + std::lock_guard lock(_mutex); + flush(); + _isSimulatingJitter = enable; +} void AudioClient::Gate::setThreshold(int threshold) { + std::lock_guard lock(_mutex); flush(); _threshold = std::max(threshold, 1); } void AudioClient::Gate::insert(QSharedPointer message) { + std::lock_guard lock(_mutex); + // Short-circuit for normal behavior - if (_threshold == 1) { + if (_threshold == 1 && !_isSimulatingJitter) { _audioClient->_receivedAudioStream.parseData(*message); return; } + // Throttle the current packet until the next flush _queue.push(message); _index++; - if (_index % _threshold == 0) { + // When appropriate, flush all held packets to the received audio stream + if (_isSimulatingJitter) { + // The JITTER_FLUSH_CHANCE defines the discrete probability density function of jitter (ms), + // where f(t) = pow(1 - JITTER_FLUSH_CHANCE, (t / 10) * JITTER_FLUSH_CHANCE + // for t (ms) = 10, 20, ... (because typical packet timegap is 10ms), + // because there is a JITTER_FLUSH_CHANCE of any packet instigating a flush of all held packets. + static const float JITTER_FLUSH_CHANCE = 0.6f; + // It is set at 0.6 to give a low chance of spikes (>30ms, 2.56%) so that they are obvious, + // but settled within the measured 5s window in audio network stats. + if (randFloat() < JITTER_FLUSH_CHANCE) { + flush(); + } + } else if (!(_index % _threshold)) { flush(); } } void AudioClient::Gate::flush() { + // Send all held packets to the received audio stream to be (eventually) played while (!_queue.empty()) { _audioClient->_receivedAudioStream.parseData(*_queue.front()); _queue.pop(); diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index c4d32e8694..926212cf47 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -132,6 +132,9 @@ public: int getOutputStarveDetectionThreshold() { return _outputStarveDetectionThreshold.get(); } void setOutputStarveDetectionThreshold(int threshold) { _outputStarveDetectionThreshold.set(threshold); } + bool isSimulatingJitter() { return _gate.isSimulatingJitter(); } + void setIsSimulatingJitter(bool enable) { _gate.setIsSimulatingJitter(enable); } + int getGateThreshold() { return _gate.getThreshold(); } void setGateThreshold(int threshold) { _gate.setThreshold(threshold); } @@ -230,7 +233,10 @@ private: class Gate { public: - Gate(AudioClient* audioClient, int threshold); + Gate(AudioClient* audioClient); + + bool isSimulatingJitter() { return _isSimulatingJitter; } + void setIsSimulatingJitter(bool enable); int getThreshold() { return _threshold; } void setThreshold(int threshold); @@ -242,11 +248,13 @@ private: AudioClient* _audioClient; std::queue> _queue; + std::mutex _mutex; + int _index{ 0 }; - int _threshold; + int _threshold{ 1 }; + bool _isSimulatingJitter{ false }; }; - Setting::Handle _gateThreshold; Gate _gate; Mutex _injectorsMutex; diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index cc022d9df2..1c177cffc4 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -198,15 +198,10 @@ void RenderableWebEntityItem::render(RenderArgs* args) { #endif if (!_webSurface) { - #if defined(Q_OS_LINUX) - // these don't seem to work on Linux - return; - #else if (!buildWebSurface(static_cast(args->_renderer))) { return; } _fadeStartTime = usecTimestampNow(); - #endif } _lastRenderTime = usecTimestampNow(); diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 739c0f8f4a..eecc1515f5 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -402,13 +402,18 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointerreadWithoutCopy(reasonSize); QString reasonMessage = QString::fromUtf8(reasonText); + quint16 extraInfoSize; + message->readPrimitive(&extraInfoSize); + auto extraInfoUtf8= message->readWithoutCopy(extraInfoSize); + QString extraInfo = QString::fromUtf8(extraInfoUtf8); + // output to the log so the user knows they got a denied connection request // and check and signal for an access token so that we can make sure they are logged in - qCWarning(networking) << "The domain-server denied a connection request: " << reasonMessage; + qCWarning(networking) << "The domain-server denied a connection request: " << reasonMessage << " extraInfo:" << extraInfo; if (!_domainConnectionRefusals.contains(reasonMessage)) { _domainConnectionRefusals.insert(reasonMessage); - emit domainConnectionRefused(reasonMessage, (int)reasonCode); + emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo); } auto accountManager = DependencyManager::get(); diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index 50639a4817..7f89b47197 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -123,7 +123,7 @@ signals: void settingsReceived(const QJsonObject& domainSettingsObject); void settingsReceiveFail(); - void domainConnectionRefused(QString reasonMessage, int reason); + void domainConnectionRefused(QString reasonMessage, int reason, const QString& extraInfo); private: bool reasonSuggestsLogin(ConnectionRefusedReason reasonCode); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 0f3d5885ff..ec4e724c1b 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -64,7 +64,7 @@ PacketVersion versionForPacketType(PacketType packetType) { return 18; // Introduction of node ignore request (which replaced an unused packet tpye) case PacketType::DomainConnectionDenied: - return static_cast(DomainConnectionDeniedVersion::IncludesReasonCode); + return static_cast(DomainConnectionDeniedVersion::IncludesExtraInfo); case PacketType::DomainConnectRequest: return static_cast(DomainConnectRequestVersion::HasProtocolVersions); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 25500b984f..aa775b9f53 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -206,7 +206,8 @@ enum class DomainConnectRequestVersion : PacketVersion { enum class DomainConnectionDeniedVersion : PacketVersion { ReasonMessageOnly = 17, - IncludesReasonCode + IncludesReasonCode, + IncludesExtraInfo }; enum class DomainServerAddedNodeVersion : PacketVersion { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index d90566c619..d673bb4653 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -184,7 +184,7 @@ var toolBar = (function () { properties.position = position; entityID = Entities.addEntity(properties); } else { - Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds."); + Window.notifyEditError("Can't create " + properties.type + ": " + properties.type + " would be out of bounds."); } selectionManager.clearSelections(); @@ -445,7 +445,7 @@ var toolBar = (function () { return; } if (active && !Entities.canRez() && !Entities.canRezTmp()) { - Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG); + Window.notifyEditError(INSUFFICIENT_PERMISSIONS_ERROR_MSG); return; } Messages.sendLocalMessage("edit-events", JSON.stringify({ @@ -1082,13 +1082,13 @@ function handeMenuEvent(menuItem) { deleteSelectedEntities(); } else if (menuItem === "Export Entities") { if (!selectionManager.hasSelection()) { - Window.alert("No entities have been selected."); + Window.notifyEditError("No entities have been selected."); } else { var filename = Window.save("Select Where to Save", "", "*.json"); if (filename) { var success = Clipboard.exportEntities(filename, selectionManager.selections); if (!success) { - Window.alert("Export failed."); + Window.notifyEditError("Export failed."); } } } @@ -1156,7 +1156,7 @@ function getPositionToImportEntity() { } function importSVO(importURL) { if (!Entities.canAdjustLocks()) { - Window.alert(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG); + Window.notifyEditError(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG); return; } @@ -1188,10 +1188,10 @@ function importSVO(importURL) { Window.raiseMainWindow(); } else { - Window.alert("Can't import objects: objects would be out of bounds."); + Window.notifyEditError("Can't import objects: objects would be out of bounds."); } } else { - Window.alert("There was an error importing the entity file."); + Window.notifyEditError("There was an error importing the entity file."); } Overlays.editOverlay(importingSVOTextOverlay, { @@ -1481,7 +1481,7 @@ var PropertiesTool = function (opts) { // If any of the natural dimensions are not 0, resize if (properties.type === "Model" && naturalDimensions.x === 0 && naturalDimensions.y === 0 && naturalDimensions.z === 0) { - Window.alert("Cannot reset entity to its natural dimensions: Model URL" + + Window.notifyEditError("Cannot reset entity to its natural dimensions: Model URL" + " is invalid or the model has not yet been loaded."); } else { Entities.editEntity(selectionManager.selections[i], { diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index f41b0502c8..f3ba466342 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -58,6 +58,8 @@ // } // } +/* global Script, Controller, Overlays, SoundArray, Quat, Vec3, MyAvatar, Menu, HMD, AudioDevice, LODManager, Settings, Camera */ + (function() { // BEGIN LOCAL_SCOPE Script.include("./libraries/soundArray.js"); @@ -76,11 +78,9 @@ var fontSize = 12.0; var PERSIST_TIME_2D = 10.0; // Time in seconds before notification fades var PERSIST_TIME_3D = 15.0; var persistTime = PERSIST_TIME_2D; -var clickedText = false; var frame = 0; var ourWidth = Window.innerWidth; var ourHeight = Window.innerHeight; -var text = "placeholder"; var ctrlIsPressed = false; var ready = true; var MENU_NAME = 'Tools > Notifications'; @@ -97,12 +97,14 @@ var NotificationType = { WINDOW_RESIZE: 3, LOD_WARNING: 4, CONNECTION_REFUSED: 5, + EDIT_ERROR: 6, properties: [ { text: "Mute Toggle" }, { text: "Snapshot" }, { text: "Window Resize" }, { text: "Level of Detail" }, - { text: "Connection Refused" } + { text: "Connection Refused" }, + { text: "Edit error" } ], getTypeFromMenuItem: function(menuItemName) { if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) { @@ -253,6 +255,9 @@ function notify(notice, button, height, imageProperties, image) { positions = calculate3DOverlayPositions(noticeWidth, noticeHeight, notice.y); + notice.parentID = MyAvatar.sessionUUID; + notice.parentJointIndex = -2; + if (!image) { notice.topMargin = 0.75 * notice.topMargin * NOTIFICATION_3D_SCALE; notice.leftMargin = 2 * notice.leftMargin * NOTIFICATION_3D_SCALE; @@ -270,6 +275,8 @@ function notify(notice, button, height, imageProperties, image) { button.url = button.imageURL; button.scale = button.width * NOTIFICATION_3D_SCALE; button.isFacingAvatar = false; + button.parentID = MyAvatar.sessionUUID; + button.parentJointIndex = -2; buttons.push((Overlays.addOverlay("image3d", button))); overlay3DDetails.push({ @@ -279,6 +286,34 @@ function notify(notice, button, height, imageProperties, image) { width: noticeWidth, height: noticeHeight }); + + + var defaultEyePosition, + avatarOrientation, + notificationPosition, + notificationOrientation, + buttonPosition; + + if (isOnHMD && notifications.length > 0) { + // Update 3D overlays to maintain positions relative to avatar + defaultEyePosition = MyAvatar.getDefaultEyePosition(); + avatarOrientation = MyAvatar.orientation; + + for (i = 0; i < notifications.length; i += 1) { + notificationPosition = Vec3.sum(defaultEyePosition, + Vec3.multiplyQbyV(avatarOrientation, + overlay3DDetails[i].notificationPosition)); + notificationOrientation = Quat.multiply(avatarOrientation, + overlay3DDetails[i].notificationOrientation); + buttonPosition = Vec3.sum(defaultEyePosition, + Vec3.multiplyQbyV(avatarOrientation, + overlay3DDetails[i].buttonPosition)); + Overlays.editOverlay(notifications[i], { position: notificationPosition, + rotation: notificationOrientation }); + Overlays.editOverlay(buttons[i], { position: buttonPosition, rotation: notificationOrientation }); + } + } + } else { if (!image) { notificationText = Overlays.addOverlay("text", notice); @@ -429,11 +464,6 @@ function update() { noticeOut, buttonOut, arraysOut, - defaultEyePosition, - avatarOrientation, - notificationPosition, - notificationOrientation, - buttonPosition, positions, i, j, @@ -457,7 +487,8 @@ function update() { Overlays.editOverlay(notifications[i], { x: overlayLocationX, y: locationY }); Overlays.editOverlay(buttons[i], { x: buttonLocationX, y: locationY + 12.0 }); if (isOnHMD) { - positions = calculate3DOverlayPositions(overlay3DDetails[i].width, overlay3DDetails[i].height, locationY); + positions = calculate3DOverlayPositions(overlay3DDetails[i].width, + overlay3DDetails[i].height, locationY); overlay3DDetails[i].notificationOrientation = positions.notificationOrientation; overlay3DDetails[i].notificationPosition = positions.notificationPosition; overlay3DDetails[i].buttonPosition = positions.buttonPosition; @@ -480,22 +511,6 @@ function update() { } } } - - if (isOnHMD && notifications.length > 0) { - // Update 3D overlays to maintain positions relative to avatar - defaultEyePosition = MyAvatar.getDefaultEyePosition(); - avatarOrientation = MyAvatar.orientation; - - for (i = 0; i < notifications.length; i += 1) { - notificationPosition = Vec3.sum(defaultEyePosition, - Vec3.multiplyQbyV(avatarOrientation, overlay3DDetails[i].notificationPosition)); - notificationOrientation = Quat.multiply(avatarOrientation, overlay3DDetails[i].notificationOrientation); - buttonPosition = Vec3.sum(defaultEyePosition, - Vec3.multiplyQbyV(avatarOrientation, overlay3DDetails[i].buttonPosition)); - Overlays.editOverlay(notifications[i], { position: notificationPosition, rotation: notificationOrientation }); - Overlays.editOverlay(buttons[i], { position: buttonPosition, rotation: notificationOrientation }); - } - } } var STARTUP_TIMEOUT = 500, // ms @@ -532,12 +547,17 @@ function onDomainConnectionRefused(reason) { createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED); } +function onEditError(msg) { + createNotification(wordWrap(msg), NotificationType.EDIT_ERROR); +} + + function onSnapshotTaken(path, notify) { if (notify) { var imageProperties = { path: "file:///" + path, aspectRatio: Window.innerWidth / Window.innerHeight - } + }; createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties); } } @@ -571,8 +591,6 @@ function keyReleaseEvent(key) { // Triggers notification on specific key driven events function keyPressEvent(key) { - var noteString; - if (key.key === 16777249) { ctrlIsPressed = true; } @@ -622,13 +640,13 @@ function menuItemEvent(menuItem) { } LODManager.LODDecreased.connect(function() { - var warningText = "\n" - + "Due to the complexity of the content, the \n" - + "level of detail has been decreased. " - + "You can now see: \n" - + LODManager.getLODFeedbackText(); + var warningText = "\n" + + "Due to the complexity of the content, the \n" + + "level of detail has been decreased. " + + "You can now see: \n" + + LODManager.getLODFeedbackText(); - if (lodTextID == false) { + if (lodTextID === false) { lodTextID = createNotification(warningText, NotificationType.LOD_WARNING); } else { Overlays.editOverlay(lodTextID, { text: warningText }); @@ -644,6 +662,7 @@ Script.scriptEnding.connect(scriptEnding); Menu.menuItemEvent.connect(menuItemEvent); Window.domainConnectionRefused.connect(onDomainConnectionRefused); Window.snapshotTaken.connect(onSnapshotTaken); +Window.notifyEditError = onEditError; setup(); diff --git a/tools/ice-client/src/ICEClientApp.cpp b/tools/ice-client/src/ICEClientApp.cpp index 1a251a45c2..992014ad7d 100644 --- a/tools/ice-client/src/ICEClientApp.cpp +++ b/tools/ice-client/src/ICEClientApp.cpp @@ -86,7 +86,7 @@ ICEClientApp::ICEClientApp(int argc, char* argv[]) : QHostAddress address { hostnamePortString.left(hostnamePortString.indexOf(':')) }; quint16 port { (quint16) hostnamePortString.mid(hostnamePortString.indexOf(':') + 1).toUInt() }; if (port == 0) { - port = 7337; + port = ICE_SERVER_DEFAULT_PORT; } if (address.isNull()) {