$options['url'] ?? $options['u'] ?? 'ws://127.0.0.1:9503/events', ]; Amp\Loop::run(function () use($options) { echo "Connecting to: {$options['url']}" . PHP_EOL; try { /** @var Connection $connection */ $connection = yield connect($options['url']); $connection->onClose(static function() use($connection) { printf("Connection closed. Reason: %s\n", $connection->getCloseReason()); }); echo 'Waiting for events...' . PHP_EOL; while ($message = yield $connection->receive()) { /** @var Message $message */ $payload = yield $message->buffer(); printf("Received event: %s\n", $payload); } } catch (\Throwable $e) { printf("Error: %s\n", $e->getMessage()); } });