-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented logic for unique rooms #820
Changes from 1 commit
dbad00c
9136e30
3b0f807
73fcf8c
ac49bb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this regex looks wrong, var query = (new URL(window.location.href)).searchParams;
this.room = query.collaboration || <random string>; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be working. Opening Another similar approach I found is : var params = window.location.href.split("?").pop();
this.room = new URLSearchParams(params).get("collaboration") || Math.random().toString(36).substring(7);
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we want to try to minimize string manipulation in urls as much as possible. I think I made a mistake in the code. Here's what it's supposed to be: var query = (new URL(window.location.href)).searchParams;
this.room = query.get("collaboration") || <random string>; |
||
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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to add the |
||
self.codemirror = codemirror; | ||
self.webrtc.sendToAll("new client", {}); | ||
self.webrtc.on("createdPeer", function(peer) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,8 +93,14 @@ | |
} | ||
|
||
function load(Bramble) { | ||
var hash = location.hash.replace(/^#/, ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the issue you file from the comment above, can you link to this piece of code as well so that we don't forget to change it as well when we move to the bramble api. |
||
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 | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's safer to include
window.location
here vs. justlocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment above saying that this is only temporary and it needs to be moved to the Bramble API?
Also, can you file a follow up issue in Thimble for this?