From 7676f0c88fa3a214254dbbe942afd81f5ab0ab52 Mon Sep 17 00:00:00 2001 From: harkirat singh Date: Fri, 7 Jul 2017 12:04:05 -0700 Subject: [PATCH] Fix mozilla/thimble.mozilla.org#2341 - Implemented logic for unique rooms (#820) * Added logic for unique rooms * Moved to window.location, Added comments * Shifted to URLSearchParams for url parsing * Shifted to searchParams * Reverted hosted.js, modified log --- src/editor/Collaboration.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/editor/Collaboration.js b/src/editor/Collaboration.js index b168af58b20..fe83d9b404b 100644 --- a/src/editor/Collaboration.js +++ b/src/editor/Collaboration.js @@ -14,6 +14,10 @@ define(function (require, exports, module) { // TODO : Shift this to config. url: "localhost:8888" }); + //To be moved to the bramble API. + var query = (new URL(window.location.href)).searchParams; + this.room = query.get("collaboration") || Math.random().toString(36).substring(7); + console.log(this.room); this.webrtc = webrtc; this.pending = []; // pending clients that need to be initialized. this.changing = false; @@ -21,7 +25,7 @@ define(function (require, exports, module) { Collaboration.prototype.init = function(codemirror) { var self = this; - this.webrtc.joinRoom('thimble', function() { + this.webrtc.joinRoom(this.room, function() { self.codemirror = codemirror; self.webrtc.sendToAll("new client", {}); self.webrtc.on("createdPeer", function(peer) {