Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix bug with heartbeat handler.

  • Loading branch information...
commit 5f78247f323df90e6aa7982f76f86aaef87afbc1 1 parent 78e9456
Eric Butler codebutler authored
15 lib/tapchat/engine.js
View
@@ -278,7 +278,7 @@
Engine.prototype.messageHandlers = {
heartbeat: function(client, message, callback) {
- var bid, buffers, cid, connection, eid, queue, seenEids, _fn,
+ var bid, buffer, buffers, cid, connection, eid, queue, seenEids, _fn,
_this = this;
this.selectedBid = message.selectedBuffer;
seenEids = JSON.parse(message.seenEids);
@@ -286,16 +286,21 @@
for (cid in seenEids) {
buffers = seenEids[cid];
connection = this.findConnection(parseInt(cid));
- _fn = function(bid, eid) {
+ if (!connection) {
+ throw "connection not found: " + cid;
+ }
+ _fn = function(buffer, eid) {
return queue.perform(function(over) {
- var buffer;
- buffer = connection.findBuffer(parseInt(bid));
return buffer.setLastSeenEid(eid, over);
});
};
for (bid in buffers) {
eid = buffers[bid];
- _fn(bid, eid);
+ buffer = connection.findBuffer(parseInt(bid));
+ if (!buffer) {
+ throw "buffer not found: " + bid;
+ }
+ _fn(buffer, eid);
}
}
queue.whenDone(function() {
2  package.json
View
@@ -1,6 +1,6 @@
{
"name": "tapchat",
- "version": "0.0.8",
+ "version": "0.0.9",
"author": {
"name": "Eric Butler",
"email": "eric@codebutler.com"
6 src/tapchat/engine.coffee
View
@@ -221,10 +221,12 @@ class Engine
for cid, buffers of seenEids
connection = @findConnection(parseInt(cid))
+ throw "connection not found: #{cid}" unless connection
for bid, eid of buffers
- do (bid, eid) =>
+ buffer = connection.findBuffer(parseInt(bid))
+ throw "buffer not found: #{bid}" unless buffer
+ do (buffer, eid) =>
queue.perform (over) =>
- buffer = connection.findBuffer(parseInt(bid))
buffer.setLastSeenEid(eid, over)
queue.whenDone =>
Please sign in to comment.
Something went wrong with that request. Please try again.