diff --git a/lib/server/session.js b/lib/server/session.js index 0a07814a..d2863082 100644 --- a/lib/server/session.js +++ b/lib/server/session.js @@ -65,9 +65,6 @@ function Session(instance, stream) { // map of collection name -> {doc name: stream || true || false} this.collections = {}; - // Map from cName -> docName -> version the client has. - this.knownVersions = {}; - // Map from query ID -> emitter. this.queries = {}; @@ -145,13 +142,6 @@ Session.prototype._setSubscribed = function(c, docName, value, v) { } // Set to new value docs[docName] = value; - - var vs = (this.knownVersions[c] || (this.knownVersions[c] = {})); - if (typeof v === 'number') { - vs[docName] = v; - } else if (!value) { - delete vs[docName]; - } }; // Check whether or not the document is subscribed by this session. @@ -503,17 +493,6 @@ Session.prototype._processQueryResults = function(collection, results, qopts) { return messages; }; -Session.prototype._mergeKnownVersions = function(collectionVersions) { - if (!collectionVersions) return; - - for (var c in collectionVersions) { - for (var docName in collectionVersions[c]) { - var vs = (this.knownVersions[c] || (this.knownVersions[c] = {})); - vs[docName] = collectionVersions[c][docName]; - } - } -} - // Handle an incoming message from the client. This is the actual guts of session.js. Session.prototype._handleMessage = function(req, callback) { // First some checks of the incoming request. Error will be set to a value if a problem is found. @@ -542,9 +521,8 @@ Session.prototype._handleMessage = function(req, callback) { if (qopts.docMode != null && qopts.docMode !== 'fetch' && qopts.docMode !== 'sub') return callback('invalid query docmode: ' + qopts.docMode); - // Fill in known query data a previous session. Ignored if docMode isn't defined. - this._mergeKnownVersions(req.o.vs); - qopts.versions = this.knownVersions; + // The client tells us what versions it already has + qopts.versions = req.o.vs; // Enables polling mode, which forces the query to be rerun on the whole // index, not just the edited document. diff --git a/package.json b/package.json index 0cb63572..3058a9f6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,11 @@ "optimist": ">= 0.2.4", "browserchannel": "*", "mocha": "~1", - "uglify-js": "~2" + "chai": "*", + "sinon": "^1.12.2", + "uglify-js": "~2", + "sinon": "^1.4.0", + "connect": "^3.3.0" }, "optionalDependencies": { "express": "~3" diff --git a/test/server/useragent.coffee b/test/server/useragent.coffee index 013e6cd3..93cfce2f 100644 --- a/test/server/useragent.coffee +++ b/test/server/useragent.coffee @@ -2,6 +2,7 @@ UserAgent = require '../../lib/server/useragent' {Readable} = require 'stream' {EventEmitter} = require 'events' assert = require 'assert' +sinon = require 'sinon' describe 'UserAgent', ->