Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent loop from being run on shutdown if it has already been run #66

Merged
merged 1 commit into from
May 22, 2018

Conversation

mbonneau
Copy link
Member

If a loop is passed into connect() and run prior to shutdown, Pawl starts it back up.

You can reproduce this behavior:

use function Ratchet\Client\connect;
use React\EventLoop\Factory;
use React\EventLoop\Timer\TimerInterface;

require __DIR__ . '/vendor/autoload.php';

$loop = Factory::create();

$loop->addPeriodicTimer(1, function (TimerInterface $timer) {
    static $x = 0;

    echo ++$x;

    if ($x === 5) {
        $timer->getLoop()->stop();
    }
});

$x = connect('ws://echo.socketo.me:9000', [], [], $loop);

$loop->run();

The expected output would be: 12345
The output without this change is: 123456789...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant