Transforms the EventQeueObject into an EventStreamObject
and returns it.

@return EventStreamObject
330410
public function getEventStreamObject(): EventStreamObject
    {
        $eventStreamObject = new EventStreamObject();
        $eventStreamObject->setUuid($this->getUuid());
        $eventStreamObject->setCommandUuid($this->getCommandUuid());
        $eventStreamObject->setVersion($this->getVersion());
        $eventStreamObject->setCreated($this->getCreated());
        $eventStreamObject->setEvent($this->getEvent());
        $eventStreamObject->setAggregateClass($this->getAggregateClass());
        $eventStreamObject->setUser($this->getUser());
        $eventStreamObject->setPayload($this->getPayload());
        $eventStreamObject->setMessage($this->getMessage());

        return $eventStreamObject;
    }
161857
protected function getStreamingWrapperCreator()
    {
        return function ($connection, $callback) {
            return function ($state, $response) use ($connection, $callback) {
                \call_user_func($callback, $response, $connection, null);
            };
        };
    }
1297672
public function getBody()
    {
        $streamResource = fopen('php://memory', 'r+');
        if (is_resource($this->content)) {
            stream_copy_to_stream($this->content, $streamResource);
        } else {
            fwrite($streamResource, $this->content);
        }
        rewind($streamResource);

        return new ContentStream($streamResource);
    }
1246832
private function outputStream(): ResourceOutputStream
    {
        if (null === $this->outputStream)
        {
            $this->outputStream = new ResourceOutputStream(self::createStream($this->host, $this->port), 65000);
        }

        return $this->outputStream;
    }
613852
public function getRemuxStream()
    {
        $urls = $this->getUrl();

        if (!isset($urls[0]) || !isset($urls[1])) {
            throw new Exception(_('This video does not have two URLs.'));
        }

        $process = new Process(
            [
                $this->config->avconv,
                '-v', $this->config->avconvVerbosity,
                '-i', $urls[0],
                '-i', $urls[1],
                '-c', 'copy',
                '-map', '0:v:0 ',
                '-map', '1:a:0',
                '-f', 'matroska',
                'pipe:1',
            ]
        );

        $stream = popen($process->getCommandLine(), 'r');
        if (!is_resource($stream)) {
            throw new Exception(_('Could not open popen stream.'));
        }

        return $stream;
    }
709399
private function getStream()
    {
        if ($this->stream && get_resource_type($this->stream) === 'Unknown') {
            fclose($this->stream);
            $this->stream = null;
        }
        if (!$this->stream) {
            $this->stream = @fopen($this->streamUrl, 'a');
            if (!$this->stream) {
                LoggerPolicy::processIOError("Error open $this->streamUrl");
                $this->stream = null;
            }
        }

        return $this->stream;
    }
198276
private function createStreamListener()
    {
        $callback = function ($event, $status, $events, $stream) {
            if (!isset($this->streamEvents[(int) $stream])) {
                return;
            }

            if (($events | 4) === 4) {
                // Disconnected
                return;
            }

            if (isset($this->readStreams[(int) $stream]) && ($events & \UV::READABLE)) {
                \call_user_func($this->readStreams[(int) $stream], $stream);
            }

            if (isset($this->writeStreams[(int) $stream]) && ($events & \UV::WRITABLE)) {
                \call_user_func($this->writeStreams[(int) $stream], $stream);
            }
        };

        return $callback;
    }
772635
protected function registerEventLoop()
    {
        $this->app->singleton(LoopInterface::class, function () {
            return new StreamSelectLoop();
        });
        $this->app->alias(LoopInterface::class, 'ami.eventloop');
    }
69538
public static function instance(): self
    {
        if (!self::$instance) {
            self::$instance = new self(
                Sequencer::sequence('event-sequence-number'),
                SystemClock::instance()
            );
        }

        return self::$instance;
    }
634406
public function getEvent() {
        if (!$this->isEvent()) {
            return EventEnum::Message;
        }
        // ADD SCAN SUBSCRIBE EVENT
        if ($this->event == EventEnum::Subscribe
            && strpos($this->eventKey, 'qrscene_') === 0) {
            $this->eventKey = Str::firstReplace($this->eventKey, 'qrscene_');
            return EventEnum::ScanSubscribe;
        }
        return $this->event;
    }
1242459
public function getBody()
    {
        if ($this->stream)
            return $this->stream;
        
        $stream = $this->httpMessage->getBody();

        if ($stream instanceof iStreamable)
            $stream = new StreamBridgeInPsr($stream);
        else {
            $body   = (string) $stream;
            $stream = new Stream('php://temp', 'wb+');
            $stream->write($body);
            $stream->rewind();
        }
        
        return $this->stream = $stream;
    }
538615
public function stream()
    {
        return $this->factory->resolve(
            $this->parser, $this->getFormat(), $this->data, 'stream'
        );
    }
184382
@Override
  public StreamImpl stream()
    throws IOException
  {
    if (_channelStream == null) {
      _channelStream = new SocketChannelStream();
    }
    
    if (_sslSocket == null) {
      _channelStream.init(_channel);
      _streamImpl = _channelStream;
    }
    else {
      if (_sslStream == null) {
        _sslStream = new SocketStream();
      }
      
      _sslStream.init(_sslSocket);
      _streamImpl = _sslStream;
    }

    return _streamImpl;
  }
1146548
private function createQueueEventObject()
    {
        $obj = clone $this->queueEventDocument;
        $obj->setEvent($this->generateRoutingKey());
        $obj->setDocumenturl($this->request->get('selfLink'));
        $obj->setStatusurl($this->getStatusUrl($obj));
        $obj->setCoreUserId($this->getSecurityUsername());

        return $obj;
    }
1156758
protected function eventCollection(): EventCollection
    {
        if ($this->eventCollection === null) {
            $this->eventCollection = new EventCollection($this->id(), Type::create($this));
        }

        return $this->eventCollection;
    }
883765
public function afterForkChild()
    {
        //possible event base free?
        unset($this->eventBase);
        unset($this->nextTickQueue);
        unset($this->futureTickQueue);
        //bugfix lambda function destructed while executing -.-
        //unset($this->timerCallback);
        //unset($this->streamCallback);
        unset($this->timerEvents);
        unset($this->running);
        $this->streamEvents = array();
        $this->streamFlags = array();
        $this->readListeners = array();
        $this->writeListeners = array();
        //call constructor
        $this->__construct();
        return $this;
    }
294344
private function appendToEventsForStream(&$eventsForStream, $serializedEvents)
    {
        // TODO: remove support of non array values by upcasters in next major release
        if (!is_array($serializedEvents)) {
            @trigger_error(
                'Upcasters need to return an array collection of upcasted events, ' .
                'non array return values are deprecated and support will be removed in the next major release',
                E_USER_DEPRECATED
            );

            $serializedEvents = [$serializedEvents];
        }

        foreach ($serializedEvents as $serializedEvent) {
            $eventsForStream[] = $this->eventFactory->createFromSerializedEvent($serializedEvent);
        }
    }