Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/felixge/node-comment into f…
Browse files Browse the repository at this point in the history
…elixge/master
  • Loading branch information
davidjrice committed Jan 29, 2010
2 parents 04b2dc1 + a6b9dd9 commit bd03568
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bin/poll_server.js
Expand Up @@ -23,7 +23,7 @@ var
changeRequest = changeClient.request(
'GET',
// Couch 0.11.x (trunk) supports ?include_docs=true, but we'll do it without
'/'+config.couchDb.db+'/_changes?feed=continuous'
'/'+config.couchDb.db+'/_changes?feed=continuous&heartbeat=30000'
);

// Avoid the http client closing the connection after 60sec
Expand Down Expand Up @@ -106,6 +106,13 @@ changeRequest.finish(function(res) {
change = buffer.substr(0, offset);
buffer = buffer.substr(offset +1);

// Couch sends an empty line as the "heartbeat"
if (change == '') {
return puts('couch heartbeat');
}

puts('couch change: '+change);

try {
if( change != "" ){
change = JSON.parse(change);
Expand All @@ -114,6 +121,10 @@ changeRequest.finish(function(res) {
throw new Error('Could not parse change line: "'+change+'"');
}

if (!change.id) {
return puts('weird couch change: '+JSON.stringify(change));
}

// Fetch the document for this change
db.openDoc(change.id, {
success: function(doc) {
Expand Down

0 comments on commit bd03568

Please sign in to comment.