getBuffer() public method

public getBuffer ( )
Beispiel #1
0
 public function testBufferEventsShouldBubbleUp()
 {
     $stream = fopen('php://temp', 'r+');
     $loop = $this->createLoopMock();
     $conn = new Stream($stream, $loop);
     $conn->on('drain', $this->expectCallableOnce());
     $conn->on('error', $this->expectCallableOnce());
     $buffer = $conn->getBuffer();
     $buffer->emit('drain');
     $buffer->emit('error', array(new \RuntimeException('Whoops')));
 }
 /**
  * Continues the given flow.
  *
  * @param ReactFlow $flow
  * @param Packet    $packet
  */
 private function continueFlow(ReactFlow $flow, Packet $packet)
 {
     try {
         $response = $flow->next($packet);
     } catch (\Exception $e) {
         $this->emitError($e);
         return;
     }
     if ($response !== null) {
         if ($this->stream->getBuffer()->listening) {
             $this->sendingFlows[] = $flow;
         } else {
             $this->stream->write($response);
             $this->writtenFlow = $flow;
         }
     } elseif ($flow->isFinished()) {
         $this->loop->nextTick(function () use($flow) {
             $this->finishFlow($flow);
         });
     }
 }