Skip to content

Commit

Permalink
Implemented logic for unique rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirat committed Jul 6, 2017
1 parent ce5d1ab commit 7321f29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/editor/Collaboration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ define(function (require, exports, module) {
// immediately ask for camera access
autoRequestMedia: false
});
var hash = location.hash.replace(/^#/, "");
var m = /&?collaboration=([^&]*)/.exec(hash);
if(m && m[1]) {
this.room = m[1];
} else {
this.room = Math.random().toString(36).substring(7);
}
console.log("Link -> http://localhost:8000/src/hosted.html#?collaboration=" + this.room);
this.webrtc = webrtc;
this.pending = []; // pending clients that need to be initialized.
this.changing = false;
};

Collaboration.prototype.init = function(codemirror) {
var self = this;
this.webrtc.joinRoom('thimble', function() {
this.webrtc.joinRoom("brackets-"+this.room, function() {
self.codemirror = codemirror;
self.webrtc.sendToAll("new client", {});
self.webrtc.on("createdPeer", function(peer) {
Expand Down
8 changes: 7 additions & 1 deletion src/hosted.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@
}

function load(Bramble) {
var hash = location.hash.replace(/^#/, "");
var m = /&?collaboration=([^&]*)/.exec(hash);
var url = "index.html";
if(m && m[1]) {
url = url + "#&collaboration=" + m[1];
}
Bramble.load("#bramble",{
url: "index.html",
url: url,
useLocationSearch: true
});

Expand Down

0 comments on commit 7321f29

Please sign in to comment.