public function push($chunk)
    {
        $this->buffer .= $chunk;

        while ($this->buffer !== '') {
            if (!isset($this->buffer[7])) {
                // last header byte not set => no complete header in buffer
                break;
            }

            $header = unpack('Cstream/x/x/x/Nlength', substr($this->buffer, 0, 8));

            if (!isset($this->buffer[7 + $header['length']])) {
                // last payload byte not set => message payload is incomplete
                break;
            }

            $payload = substr($this->buffer, 8, $header['length']);
            $this->buffer = (string)substr($this->buffer, 8 + $header['length']);

            $this->emit(
                ($header['stream'] === 2) ? $this->stderrEvent : 'data',
                array($payload)
            );
        }
    }
public function push($chunk)
    {
        $this->buffer .= $chunk;

        while ($this->buffer !== '') {
            if (!isset($this->buffer[7])) {
                // last header byte not set => no complete header in buffer
                break;
            }

            $header = unpack('Cstream/x/x/x/Nlength', substr($this->buffer, 0, 8));

            if (!isset($this->buffer[7 + $header['length']])) {
                // last payload byte not set => message payload is incomplete
                break;
            }

            $payload = substr($this->buffer, 8, $header['length']);
            $this->buffer = (string)substr($this->buffer, 8 + $header['length']);

            $this->emit(
                ($header['stream'] === 2) ? $this->stderrEvent : 'data',
                array($payload)
            );
        }
    }
public function push ( $ chunk ) { $ this -> buffer .= $ chunk ; while ( $ this -> buffer !== '' ) { if ( ! isset ( $ this -> buffer [ 7 ] ) ) { // last header byte not set => no complete header in buffer break ; } $ header = unpack ( 'Cstream/x/x/x/Nlength' , substr ( $ this -> buffer , 0 , 8 ) ) ; if ( ! isset ( $ this -> buffer [ 7 + $ header [ 'length' ] ] ) ) { // last payload byte not set => message payload is incomplete break ; } $ payload = substr ( $ this -> buffer , 8 , $ header [ 'length' ] ) ; $ this -> buffer = ( string ) substr ( $ this -> buffer , 8 + $ header [ 'length' ] ) ; $ this -> emit ( ( $ header [ 'stream' ] === 2 ) ? $ this -> stderrEvent : 'data' , array ( $ payload ) ) ; } }
push the given stream chunk into the parser buffer and try to extract all frames

@internal
@param string $chunk
push the given stream chunk into the parser buffer and try to extract all frames