added new socket manager, errorhandling and testing is not finished yet
This commit is contained in:
33
libs/React/Stream/ThroughStream.php
Normal file
33
libs/React/Stream/ThroughStream.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace React\Stream;
|
||||
|
||||
class ThroughStream extends CompositeStream
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$readable = new ReadableStream();
|
||||
$writable = new WritableStream();
|
||||
|
||||
parent::__construct($readable, $writable);
|
||||
}
|
||||
|
||||
public function filter($data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function write($data)
|
||||
{
|
||||
$this->readable->emit('data', array($this->filter($data), $this));
|
||||
}
|
||||
|
||||
public function end($data = null)
|
||||
{
|
||||
if (null !== $data) {
|
||||
$this->readable->emit('data', array($this->filter($data), $this));
|
||||
}
|
||||
|
||||
$this->writable->end($data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user