mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
livedata: if client_convenience.js is loaded "on the server" (not normally possible in the usual build scenario, but would be the case of a nodejs-based client, eg, a command-line tool), don't try to open a default DDP connection
This commit is contained in:
committed by
Naomi Seyfer
parent
71dd67b90d
commit
2bcd692b54
@@ -1,22 +1,28 @@
|
||||
// By default, try to connect back to the same endpoint as the page
|
||||
// was served from.
|
||||
var ddpUrl = '/';
|
||||
if (typeof __meteor_runtime_config__ !== "undefined") {
|
||||
if (__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL)
|
||||
ddpUrl = __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL;
|
||||
}
|
||||
|
||||
_.extend(Meteor, {
|
||||
default_connection: Meteor.connect(ddpUrl, true /* restart_on_update */),
|
||||
|
||||
default_connection: null,
|
||||
refresh: function (notification) {
|
||||
}
|
||||
});
|
||||
|
||||
// Proxy the public methods of Meteor.default_connection so they can
|
||||
// be called directly on Meteor.
|
||||
_.each(['subscribe', 'methods', 'call', 'apply', 'status', 'reconnect'],
|
||||
function (name) {
|
||||
Meteor[name] = _.bind(Meteor.default_connection[name],
|
||||
Meteor.default_connection);
|
||||
});
|
||||
if (Meteor.isClient) {
|
||||
// By default, try to connect back to the same endpoint as the page
|
||||
// was served from.
|
||||
var ddpUrl = '/';
|
||||
if (typeof __meteor_runtime_config__ !== "undefined") {
|
||||
if (__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL)
|
||||
ddpUrl = __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL;
|
||||
}
|
||||
Meteor.default_connection =
|
||||
Meteor.connect(ddpUrl, true /* restart_on_update */);
|
||||
|
||||
// Proxy the public methods of Meteor.default_connection so they can
|
||||
// be called directly on Meteor.
|
||||
_.each(['subscribe', 'methods', 'call', 'apply', 'status', 'reconnect'],
|
||||
function (name) {
|
||||
Meteor[name] = _.bind(Meteor.default_connection[name],
|
||||
Meteor.default_connection);
|
||||
});
|
||||
} else {
|
||||
/* Never set up a default connection on the server. Don't even map
|
||||
subscribe/call/etc onto Meteor. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user