React\Stream\Stream::close PHP Метод

close() публичный Метод

public close ( )
    public function close()
    {
        if (!$this->writable && !$this->closing) {
            return;
        }
        $this->closing = false;
        $this->readable = false;
        $this->writable = false;
        $this->emit('end', array($this));
        $this->emit('close', array($this));
        $this->loop->removeStream($this->stream);
        $this->buffer->removeAllListeners();
        $this->removeAllListeners();
        $this->handleClose();
    }

Usage Example

 /**
  * @dataProvider loopProvider
  */
 public function testBufferReadsLargeChunks($condition, $loopFactory)
 {
     if (true !== $condition()) {
         return $this->markTestSkipped('Loop implementation not available');
     }
     $loop = $loopFactory();
     list($sockA, $sockB) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
     $streamA = new Stream($sockA, $loop);
     $streamB = new Stream($sockB, $loop);
     $bufferSize = 4096;
     $streamA->bufferSize = $bufferSize;
     $streamB->bufferSize = $bufferSize;
     $testString = str_repeat("*", $streamA->bufferSize + 1);
     $buffer = "";
     $streamB->on('data', function ($data, $streamB) use(&$buffer, &$testString) {
         $buffer .= $data;
     });
     $streamA->write($testString);
     $loop->tick();
     $loop->tick();
     $loop->tick();
     $streamA->close();
     $streamB->close();
     $this->assertEquals($testString, $buffer);
 }
All Usage Examples Of React\Stream\Stream::close