From 8b3e5147c9640988308f2ec9a2ebdeb982b1c725 Mon Sep 17 00:00:00 2001
From: joni <johnfshaughnessy@gmail.com>
Date: Mon, 16 Apr 2018 15:24:32 -0700
Subject: [PATCH] Add blocking and unblocking functions.

---
 src/hub.js | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/hub.js b/src/hub.js
index 75111f9c6..f746abac9 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -196,6 +196,29 @@ async function enterScene(mediaStream, enterInVR, janusRoomId) {
     screenEntity.setAttribute("visible", sharingScreen);
   });
 
+  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);
+  };
+
+  document.body.addEventListener("blocked", ev => {
+    console.log("blocked");
+    NAF.connection.entities.removeEntitiesOfClient(ev.detail.by);
+  });
+
+  document.body.addEventListener("unblocked", ev => {
+    console.log("unblocked");
+    NAF.connection.entities.completeSync(ev.detail.by);
+  });
+
   if (!qsTruthy("offline")) {
     document.body.addEventListener("connected", () => {
       hubChannel.sendEntryEvent().then(() => {
-- 
GitLab