Closed jeffreydwalter closed 10 years ago
The rationale here is that in case of framer failure there is no point of keeping connection alive. Also, this code emits error on incoming PING requests not responses, so we don't have any cb
to execute in case of error.
What's the rationale behind emitting an error event, but taking a callback for the success case? Why not just emit success?
Connection.prototype._handlePing = function handlePing(id) { var self = this; var state = this._spdyState;
var ours = state.isServer && (id % 2 === 0) || !state.isServer && (id % 2 === 1);
// Handle incoming PING if (!ours) { state.framer.pingFrame(id, function(err, frame) { if (err) return self.emit('error', err); self.write(frame); }); return; }
// Handle reply PING if (!state.pings[id]) return; var ping = state.pings[id]; delete state.pings[id];
if (ping.cb) ping.cb(null); };