src/EventSender.php
/**
     * Send response through Symfony StreamedResponse
     *
     * @return StreamedResponse
     */
Send response through Symfony StreamedResponse
@return StreamedResponse
Send response through Symfony StreamedResponse @return StreamedResponse
public function send(): StreamedResponse
    {
        $this->response->setCallback(
            function () {
                while (count($this->listeners[self::ON_START]) > 0) {
                    $onStartListener = array_shift($this->listeners[self::ON_START]);
                    $onStartListener($this->buffer);
                }
                while (true) {
                    if (empty($this->listeners[self::ON_WRITE])) {
                        break;
                    }
                    $shouldStop = false;
                    while (count($this->listeners[self::ON_WRITE]) > 0) {
                        $onWriteListener = array_shift($this->listeners[self::ON_WRITE]);
                        $shouldStop = $shouldStop || $onWriteListener($this->buffer);
                    }
                    if (true === $shouldStop) {
                        break;
                    }
                    ob_flush();
                    flush();
                    usleep($this->sleep * 1000000);
                    if (1 === connection_aborted()) {
                        break;
                    }
                }
                while (count($this->listeners[self::ON_STOP]) > 0) {
                    $onStopListener = array_shift($this->listeners[self::ON_STOP]);
                    $onStopListener($this->buffer);
                }
            }
        );
        return $this->response->send();
    }
public function send ( ) : StreamedResponse { $ this -> response -> setCallback ( function ( ) { while ( count ( $ this -> listeners [ self :: ON_START ] ) > 0 ) { $ onStartListener = array_shift ( $ this -> listeners [ self :: ON_START ] ) ; $ onStartListener ( $ this -> buffer ) ; } while ( true ) { if ( empty ( $ this -> listeners [ self :: ON_WRITE ] ) ) { break ; } $ shouldStop = false ; while ( count ( $ this -> listeners [ self :: ON_WRITE ] ) > 0 ) { $ onWriteListener = array_shift ( $ this -> listeners [ self :: ON_WRITE ] ) ; $ shouldStop = $ shouldStop || $ onWriteListener ( $ this -> buffer ) ; } if ( true === $ shouldStop ) { break ; } ob_flush ( ) ; flush ( ) ; usleep ( $ this -> sleep * 1000000 ) ; if ( 1 === connection_aborted ( ) ) { break ; } } while ( count ( $ this -> listeners [ self :: ON_STOP ] ) > 0 ) { $ onStopListener = array_shift ( $ this -> listeners [ self :: ON_STOP ] ) ; $ onStopListener ( $ this -> buffer ) ; } } ) ; return $ this -> response -> send ( ) ; }
Send response through Symfony StreamedResponse
 @return StreamedResponse
Send response through Symfony StreamedResponse @return StreamedResponse