Skip to content

Commit

Permalink
Revert "Adding a little buffer to cope with slow connections."
Browse files Browse the repository at this point in the history
This reverts commit cf506ba.

Conflicts:
	lib/connection.js
  • Loading branch information
mcollina committed Jul 21, 2013
1 parent 130b3c2 commit ff1e3ed
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ var events = require('events')
, generate = require('./generate')
, parse = require('./parse')
, Writable = require("stream").Writable
, PassThrough = require("stream").PassThrough
, delay = global.setImmediate;

var Writable = require("stream").Writable

if (!Writable) {
Writable = require("readable-stream").Writable;
PassThrough = require("readable-stream").PassThrough;
}

if(!delay) {
Expand All @@ -31,20 +31,17 @@ function Connection(stream, server) {
};
util.inherits(Connection, events.EventEmitter);

Connection.prototype._setup = function() {
Connection.prototype._setupParser = function() {
this.parser = this.stream.pipe(new PacketParser({
connection: this
}));

this.bufferer = new PassThrough();
this.bufferer.pipe(this.stream);
};

Connection.prototype.reconnect = function(stream) {
var that = this;

this.stream = stream;
this._setup();
this._setupParser();
};

for (var k in protocol.types) {
Expand All @@ -54,8 +51,8 @@ for (var k in protocol.types) {
" var p = this.generate." + v +"(arguments[0]); " +
" if (p instanceof Error) { " +
" this.emit('error', p) " +
" } else if(!this.bufferer.write(p)) { " +
" this.emit('error', 'Unable to write on the stream'); " +
" } else { " +
" this.stream.write(p); " +
" } "
" } ";

Expand Down

0 comments on commit ff1e3ed

Please sign in to comment.