diff --git a/package.json b/package.json index 219811f62a5a6226c7d26fe712205e580c8f1858..c8b32fefbb3e321c087acc96644651093007fc3b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "moment": "^2.22.0", "moment-timezone": "^0.5.14", "moving-average": "^1.0.0", - "naf-janus-adapter": "^0.5.2", + "naf-janus-adapter": "https://github.com/mozilla/naf-janus-adapter#feature/blocking", "networked-aframe": "https://github.com/mozillareality/networked-aframe#mr-social-client/master", "nipplejs": "^0.6.7", "phoenix": "^1.3.0", diff --git a/src/components/block-button.js b/src/components/block-button.js index 5ea1b9fb34eebdc540da6a1343af64ba964eb004..ddfdd6485aecf132cb1e48894d2ee3eef4198e49 100644 --- a/src/components/block-button.js +++ b/src/components/block-button.js @@ -1,3 +1,16 @@ +window.blockUser = function(id) { + NAF.connection.adapter.publisher.handle.sendMessage({ kind: "block", whom: id }); + NAF.connection.entities.removeEntitiesOfClient(id); +}; + +window.unblockUser = function(id) { + NAF.connection.adapter.publisher.handle.sendMessage({ kind: "unblock", whom: id }); + window.setTimeout(() => { + // Wait enough time for the unblock to be processed + NAF.connection.entities.completeSync(id); + }, 1000); +}; + AFRAME.registerComponent("block-button", { init() { this.el.addEventListener("click", this.onClick); @@ -12,7 +25,7 @@ AFRAME.registerComponent("block-button", { })(this.el); this.onClick = () => { - console.log("blockUser " + owner); + window.blockUser(owner); }; } }); diff --git a/src/hub.html b/src/hub.html index aff18e1d4e5cc8b54d69bdef2d2a2c7f79a78b9d..f230cac6a3b10ae6429ee0dc8a6d08ac75aa8176 100644 --- a/src/hub.html +++ b/src/hub.html @@ -95,14 +95,14 @@ <a-entity personal-space-invader="radius: 0.2; useMaterial: true;" bone-visibility> </a-entity> <a-entity billboard> <a-entity + block-button visible-while-frozen text-button="haptic:#player-right-controller; textEl:.text; textHoverColor: #f00; textColor: #fff; backgroundHoverColor: #f00; - backgroundColor: #fff; - " + backgroundColor: #fff;" slice9="width: 0.45; height: 0.2; left: 53; diff --git a/src/hub.js b/src/hub.js index 5625673757ce051f569c55ac0498b8fd632a423a..1c0467d28fc0a5df455d5c2b33b70ccdd0cc1644 100644 --- a/src/hub.js +++ b/src/hub.js @@ -206,6 +206,14 @@ async function enterScene(mediaStream, enterInVR, janusRoomId) { screenEntity.setAttribute("visible", sharingScreen); }); + document.body.addEventListener("blocked", ev => { + NAF.connection.entities.removeEntitiesOfClient(ev.detail.by); + }); + + document.body.addEventListener("unblocked", ev => { + NAF.connection.entities.completeSync(ev.detail.by); + }); + if (!qsTruthy("offline")) { document.body.addEventListener("connected", () => { hubChannel.sendEntryEvent().then(() => { diff --git a/yarn.lock b/yarn.lock index 15edf71c1aed3e12ac16b63174f0cb2934c8a9d7..1464c3691709db1925805c198386b844e79c3cb4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5312,9 +5312,9 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -naf-janus-adapter@^0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/naf-janus-adapter/-/naf-janus-adapter-0.5.2.tgz#f4a9522c4e0b38fcbfe7c71b668afed67d5e133e" +"naf-janus-adapter@https://github.com/mozilla/naf-janus-adapter#feature/blocking": + version "0.5.1" + resolved "https://github.com/mozilla/naf-janus-adapter#a16d36b131c09b535098d732ccd310dc050d1add" dependencies: debug "^3.1.0" minijanus "^0.5.0"