src/Client.php
public function getEvents()
    {
        $buffer = '';
        $body = $this->response->getBody();
        while (true) {
            // if server close connection - try to reconnect
            if ($body->eof()) {
                // wait retry period before reconnection
                sleep($this->retry / 1000);
                $this->connect();
                // clear buffer since there is no sense in partial message
                $buffer = '';
            }

            $buffer .= $body->read(1);
            if (preg_match(self::END_OF_MESSAGE, $buffer)) {
                $parts = preg_split(self::END_OF_MESSAGE, $buffer, 2);

                $rawMessage = $parts[0];
                $remaining = $parts[1];

                $buffer = $remaining;

                $event = Event::parse($rawMessage);

                // if message contains id set it to last received message id
                if ($event->getId()) {
                    $this->lastId = $event->getId();
                }

                // take into account server request for reconnection delay
                if ($event->getRetry()) {
                    $this->retry = $event->getRetry();
                }

                yield $event;
            }
        }
    }
public function getEvents()
    {
        $buffer = '';
        $body = $this->response->getBody();
        while (true) {
            // if server close connection - try to reconnect
            if ($body->eof()) {
                // wait retry period before reconnection
                sleep($this->retry / 1000);
                $this->connect();
                // clear buffer since there is no sense in partial message
                $buffer = '';
            }

            $buffer .= $body->read(1);
            if (preg_match(self::END_OF_MESSAGE, $buffer)) {
                $parts = preg_split(self::END_OF_MESSAGE, $buffer, 2);

                $rawMessage = $parts[0];
                $remaining = $parts[1];

                $buffer = $remaining;

                $event = Event::parse($rawMessage);

                // if message contains id set it to last received message id
                if ($event->getId()) {
                    $this->lastId = $event->getId();
                }

                // take into account server request for reconnection delay
                if ($event->getRetry()) {
                    $this->retry = $event->getRetry();
                }

                yield $event;
            }
        }
    }
public function getEvents ( ) { $ buffer = '' ; $ body = $ this -> response -> getBody ( ) ; while ( true ) { // if server close connection - try to reconnect if ( $ body -> eof ( ) ) { // wait retry period before reconnection sleep ( $ this -> retry / 1000 ) ; $ this -> connect ( ) ; // clear buffer since there is no sense in partial message $ buffer = '' ; } $ buffer .= $ body -> read ( 1 ) ; if ( preg_match ( self :: END_OF_MESSAGE , $ buffer ) ) { $ parts = preg_split ( self :: END_OF_MESSAGE , $ buffer , 2 ) ; $ rawMessage = $ parts [ 0 ] ; $ remaining = $ parts [ 1 ] ; $ buffer = $ remaining ; $ event = Event :: parse ( $ rawMessage ) ; // if message contains id set it to last received message id if ( $ event -> getId ( ) ) { $ this -> lastId = $ event -> getId ( ) ; } // take into account server request for reconnection delay if ( $ event -> getRetry ( ) ) { $ this -> retry = $ event -> getRetry ( ) ; } yield $ event ; } } }
Returns generator that yields new event when it's available on stream.

@return Event[]
Returns generator that yields new event when it s available on stream .