mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Revert "Support unlimited tabs by working around browser per-hostname connection limits."
This reverts commit 2495cb2f58.
This change made it easy to construct URLs with more than 63 characters in a
label, which is not legal. We will redo this later with generating a smaller
random token (and taking other precautions to limit the total size of the
label).
This commit is contained in:
@@ -278,8 +278,8 @@ Template.api.connect = {
|
||||
descr: ["Connect to the server of a different Meteor application to subscribe to its document sets and invoke its remote methods."],
|
||||
args: [
|
||||
{name: "url",
|
||||
type: "String or function",
|
||||
descr: "The URL of another Meteor application. May be a function returning an URL string, or an URL string. The function will be called each time an URL is needed (immediately and on reconnects); it is expected to always return URLs pointing to the same server, but may add randomness to the hostname in order to get around browser per-hostname connection limitations. If a string is provided and it contains the string `MeteorWildcard`, that substring will be replaced by a random string of alphanumerics and hyphens."}
|
||||
type: "String",
|
||||
descr: "The URL of another Meteor application."}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -10,12 +10,21 @@ if (Meteor.isServer) {
|
||||
// XXX namespacing
|
||||
Meteor._capture_subs = null;
|
||||
|
||||
// @param url {Function|String|Object} URL or URL-producing function to Meteor
|
||||
// app or sockjs endpoint (deprecated), or an object as a test hook (see
|
||||
// code)
|
||||
// @param url {String|Object} URL to Meteor app or sockjs endpoint (deprecated),
|
||||
// or an object as a test hook (see code)
|
||||
Meteor._LivedataConnection = function (url, restart_on_update) {
|
||||
var self = this;
|
||||
|
||||
// as a test hook, allow passing a stream instead of a url.
|
||||
if (typeof url === "object") {
|
||||
self.stream = url;
|
||||
// if we have two test streams, auto reload stuff will break because
|
||||
// the url is used as a key for the migration data.
|
||||
self.url = "/debug";
|
||||
} else {
|
||||
self.url = url;
|
||||
}
|
||||
|
||||
self.last_session_id = null;
|
||||
self.stores = {}; // name -> object with methods
|
||||
self.method_handlers = {}; // name -> func
|
||||
@@ -55,13 +64,8 @@ Meteor._LivedataConnection = function (url, restart_on_update) {
|
||||
return [true];
|
||||
});
|
||||
|
||||
// Set up stream. As a test hook, allow passing a stream instead of an url or
|
||||
// url-producing function.
|
||||
if (typeof url === "object") {
|
||||
self.stream = url;
|
||||
} else {
|
||||
self.stream = new Meteor._Stream(url);
|
||||
}
|
||||
// Setup stream (if not overriden above)
|
||||
self.stream = self.stream || new Meteor._Stream(self.url);
|
||||
|
||||
self.stream.on('message', function (raw_msg) {
|
||||
try {
|
||||
@@ -557,8 +561,7 @@ _.extend(Meteor._LivedataConnection.prototype, {
|
||||
});
|
||||
|
||||
_.extend(Meteor, {
|
||||
// @param url {String|Function} URL or URL-producing function to Meteor app,
|
||||
// or to sockjs endpoint (deprecated),
|
||||
// @param url {String} URL to Meteor app, or to sockjs endpoint (deprecated),
|
||||
// e.g.:
|
||||
// "subdomain.meteor.com",
|
||||
// "http://subdomain.meteor.com",
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
// @param url {Function|String} URL or URL-producing function to Meteor app or
|
||||
// sockjs endpoint (deprecated) "http://subdomain.meteor.com/sockjs" or
|
||||
// "/sockjs"
|
||||
// @param url {String} URL to Meteor app or sockjs endpoint (deprecated)
|
||||
// "http://subdomain.meteor.com/sockjs" or "/sockjs"
|
||||
Meteor._Stream = function (url) {
|
||||
var self = this;
|
||||
|
||||
if (typeof(url) === 'string') {
|
||||
self.url = function () {
|
||||
return url.replace(/MeteorWildcard/g, Meteor.uuid);
|
||||
};
|
||||
} else if (typeof(url) === 'function') {
|
||||
self.url = url;
|
||||
} else {
|
||||
throw new Error("Stream url must be string or function: " + url);
|
||||
}
|
||||
|
||||
self.url = Meteor._Stream._toSockjsUrl(url);
|
||||
self.socket = null;
|
||||
self.event_callbacks = {}; // name -> [callback]
|
||||
self.server_id = null;
|
||||
@@ -323,16 +313,12 @@ _.extend(Meteor._Stream.prototype, {
|
||||
var self = this;
|
||||
self._cleanup_socket(); // cleanup the old socket, if there was one.
|
||||
|
||||
// Generate a new URL each time we open a connection, so that we can connect
|
||||
// to random hostnames and get around browser per-host connection limits.
|
||||
self.socket = new SockJS(
|
||||
Meteor._Stream._toSockjsUrl(self.url()),
|
||||
undefined,
|
||||
{ debug: false, protocols_whitelist: [
|
||||
// only allow polling protocols. no websockets or streaming.
|
||||
// streaming makes safari spin, and websockets hurt chrome.
|
||||
'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'
|
||||
]});
|
||||
self.socket = new SockJS(self.url, undefined, {
|
||||
debug: false, protocols_whitelist: [
|
||||
// only allow polling protocols. no websockets or streaming.
|
||||
// streaming makes safari spin, and websockets hurt chrome.
|
||||
'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'
|
||||
]});
|
||||
self.socket.onmessage = function (data) {
|
||||
// first message we get when we're connecting goes to _connected,
|
||||
// which connects us. All subsequent messages (while connected) go to
|
||||
|
||||
Reference in New Issue
Block a user