diff --git a/packages/livedata/client_convenience.js b/packages/livedata/client_convenience.js index 3eb4ef8ddc..b049d630c4 100644 --- a/packages/livedata/client_convenience.js +++ b/packages/livedata/client_convenience.js @@ -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. */ +}