Skip to content

Commit

Permalink
fix stream
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjscc committed Nov 14, 2024
1 parent 4f80c02 commit 2828fa3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Bandwidth.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function file(string $path, $p = 0, $length = -1)

public function stream($stream)
{
$stream = new \React\Stream\ThroughStream();
$stream->on('data', function ($data) use ($stream) {
$this->concurrent->concurrent(function() use ($stream, $data){
return $this->bucket->removeTokens(1024 * strlen($data))->then(function () use ($stream, $data) {
$stream->write($data);
$_stream = new \React\Stream\ThroughStream();
$stream->on('data', function ($data) use ($_stream) {
$this->concurrent->concurrent(function() use ($_stream, $data){
return $this->bucket->removeTokens(1024 * strlen($data))->then(function () use ($_stream, $data) {
$_stream->write($data);
});
});
});
return $stream;
return $_stream;
}

protected function fileStream($file, $stream, $p, $size)
Expand Down

0 comments on commit 2828fa3

Please sign in to comment.