Skip to content

Commit

Permalink
Simplify interaction between Stream and Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Nov 13, 2016
1 parent 8cc22ba commit 6bb591e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ public function __construct($stream, LoopInterface $loop, WritableStreamInterfac

$this->buffer->on('error', function ($error) use ($that) {
$that->emit('error', array($error, $that));
$that->close();
});

$this->buffer->on('close', array($this, 'close'));

$this->buffer->on('drain', function () use ($that) {
$that->emit('drain', array($that));
});
Expand Down Expand Up @@ -118,7 +119,7 @@ public function close()
$this->emit('end', array($this));
$this->emit('close', array($this));
$this->loop->removeStream($this->stream);
$this->buffer->removeAllListeners();
$this->buffer->close();
$this->removeAllListeners();

$this->handleClose();
Expand All @@ -135,8 +136,6 @@ public function end($data = null)
$this->readable = false;
$this->writable = false;

$this->buffer->on('close', array($this, 'close'));

$this->buffer->end($data);
}

Expand Down

0 comments on commit 6bb591e

Please sign in to comment.