Skip to content

Commit

Permalink
Merge pull request #372 from bruchu/remove-known-versions
Browse files Browse the repository at this point in the history
Remove known versions
  • Loading branch information
nateps committed Apr 24, 2015
2 parents ef189e7 + 1e3633c commit 935f8d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
26 changes: 2 additions & 24 deletions lib/server/session.js
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/server/useragent.coffee
Expand Up @@ -2,6 +2,7 @@ UserAgent = require '../../lib/server/useragent'
{Readable} = require 'stream'
{EventEmitter} = require 'events'
assert = require 'assert'
sinon = require 'sinon'

describe 'UserAgent', ->

Expand Down

0 comments on commit 935f8d0

Please sign in to comment.