websocket-events add reconection loop.

This commit is contained in:
Alexander Pankratov 2021-02-27 01:29:44 +03:00
parent 2a1e2aeada
commit 9acd4e6c33

View File

@ -23,6 +23,7 @@ $options = [
Amp\Loop::run(static function () use($options) {
echo "Connecting to: {$options['url']}" . PHP_EOL;
while(true) {
try {
/** @var Connection $connection */
$connection = yield connect($options['url']);
@ -40,5 +41,7 @@ Amp\Loop::run(static function () use($options) {
} catch (\Throwable $e) {
printf("Error: %s\n", $e->getMessage());
}
yield new Amp\Delayed(500);
}
});